reactpy-django icon indicating copy to clipboard operation
reactpy-django copied to clipboard

`login` / `logout` functions

Open Archmonger opened this issue 1 year ago • 1 comments

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 avatar Jan 05 '24 12:01 Archmonger

Blocked on https://github.com/reactive-python/reactpy/pull/1084

Archmonger avatar Jan 11 '24 02:01 Archmonger

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

kumaraguru1735 avatar Oct 23 '24 08:10 kumaraguru1735

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.

Archmonger avatar Oct 23 '24 15:10 Archmonger

My undying admiration for your commit/ment.

numpde avatar Oct 23 '24 16:10 numpde

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 avatar Oct 23 '24 19:10 Archmonger