File tree 3 files changed +7
-9
lines changed
3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,15 @@ async def synchronize_session_watchdog():
52
52
set_synchronize_requested (False )
53
53
54
54
async def synchronize_session ():
55
- """Entrypoint where the server will command the client to switch HTTP sessions
56
- to match the websocket session. This function is stored in the websocket scope so that
57
- ReactPy-Django's hooks can access it."""
55
+ """Event that can command the client to switch HTTP sessions (to match the websocket sessions)."""
58
56
session : SessionBase | None = scope .get ("session" )
59
57
if not session or not session .session_key :
60
58
return
61
59
62
60
# Delete any sessions currently associated with the previous UUID.
63
61
# This exists to fix scenarios where...
64
- # 1) A component tree performs multiple login commands for different users .
65
- # 2) A login is requested , but the server failed to respond to the HTTP request.
62
+ # 1) Login is called multiple times before the first one is completed .
63
+ # 2) Login was called , but the server failed to respond to the HTTP request.
66
64
if uuid .current :
67
65
with contextlib .suppress (SynchronizeSession .DoesNotExist ):
68
66
obj = await SynchronizeSession .objects .aget (uuid = uuid .current )
Original file line number Diff line number Diff line change @@ -418,15 +418,15 @@ def use_root_id() -> str:
418
418
419
419
420
420
def use_auth ():
421
- """Provides the ability to login/logout a user using Django's standard authentication framework."""
421
+ """Provides the ability to login/logout a user using Django's authentication framework."""
422
422
from reactpy_django import config
423
423
424
424
scope = use_scope ()
425
425
426
426
async def login (user : AbstractUser ):
427
427
await channels_auth .login (scope , user , backend = config .REACTPY_AUTH_BACKEND )
428
- session_save_func = getattr (scope ["session" ], "asave" , scope ["session" ].save )
429
- await ensure_async (session_save_func )()
428
+ session_save_method = getattr (scope ["session" ], "asave" , scope ["session" ].save )
429
+ await ensure_async (session_save_method )()
430
430
await scope ["reactpy" ]["synchronize_session" ]()
431
431
432
432
async def logout (rerender : bool = True ):
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class ComponentSession(models.Model):
21
21
22
22
23
23
class SynchronizeSession (models .Model ):
24
- """A model for stores any relevant data needed to force Django's HTTP session to
24
+ """A model that contains any relevant data needed to force Django's HTTP session to
25
25
match the websocket session.
26
26
27
27
This data is tied to an arbitrary UUID for security (obfuscation) purposes.
You can’t perform that action at this time.
0 commit comments