`login` / `logout` functions
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_messengerhook. Will likely be an AJAX HTTP POST request.
Blocked on https://github.com/reactive-python/reactpy/pull/1084
Reactpy is a dead project, so how can u do that ?
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.
My undying admiration for your commit/ment.
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( ... )