Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login / logout functions #204

Open
Archmonger opened this issue Jan 5, 2024 · 6 comments
Open

login / logout functions #204

Archmonger opened this issue Jan 5, 2024 · 6 comments

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Jan 5, 2024

Current Situation

The login function supplied by Django Channels provides non-persistent access to the Django session due to technical limitations.

The reason is that WebSockets are unable to modify HTTP cookies. Unfortunately, HTTP cookies are required to persist Django login state changes.

Proposed Actions

This might need to be implemented as a use_auth hook.

On a technical level, the following will need to be developed:

  • Server Side: Create a HTTP login view that accepts a UUID. This UUID will be attached to a session, which valid for 60 seconds (configurable). Somehow will need to refresh the scope['session'] after a successful authentication.
  • Client Side: Perform the login/logout via client JavaScript using the upcoming use_messenger hook. Will likely be an AJAX HTTP POST request.
@Archmonger
Copy link
Contributor Author

Blocked on reactive-python/reactpy#1084

@kumaraguru1735
Copy link

Reactpy is a dead project, so how can u do that ?

@Archmonger
Copy link
Contributor Author

My co-founder Ryan has largely been MIA for the last year, so I will need to take over development on core soon.

In the next two weeks, I will be finalizing two more features in reactpy-router then shifting my focus to core.

@numpde
Copy link

numpde commented Oct 23, 2024

My undying admiration for your commit/ment.

@Archmonger
Copy link
Contributor Author

Archmonger commented Oct 23, 2024

I'm leaning towards releasing a temporary solution to this problem.

In an ideal world, we'd have a login function that can be used within event handlers.

But due to being blocked on the use_messenger PR, I am debating temporarily releasing a login component. When rendered, this login object would perform a login operation.

@component
def example():
    ...

    if needs_login:
        return html.div( ... , login(UserObject) )

    return html.div( ... )

@Archmonger
Copy link
Contributor Author

I thought of a way to develop this in a hook-like fashion despite the lack of a use_messenger hook.

This feature will be developed soon.

@Archmonger Archmonger removed the blocked label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants