From 023df877e7d95c5445b68ef186d52b1dca0159cf Mon Sep 17 00:00:00 2001 From: Archmonger <16909269+Archmonger@users.noreply.github.com> Date: Sun, 29 Dec 2024 01:19:49 -0800 Subject: [PATCH] self review --- docs/src/reference/hooks.md | 6 ++--- src/reactpy_django/auth/components.py | 4 ++-- ...{0007_authsession.py => 0007_authtoken.py} | 6 ++--- .../0008_rename_authsession_switchsession.py | 17 -------------- ...rename_switchsession_synchronizesession.py | 17 -------------- ...e_synchronizesession_authtoken_and_more.py | 22 ------------------- 6 files changed, 8 insertions(+), 64 deletions(-) rename src/reactpy_django/migrations/{0007_authsession.py => 0007_authtoken.py} (69%) delete mode 100644 src/reactpy_django/migrations/0008_rename_authsession_switchsession.py delete mode 100644 src/reactpy_django/migrations/0009_rename_switchsession_synchronizesession.py delete mode 100644 src/reactpy_django/migrations/0010_rename_synchronizesession_authtoken_and_more.py diff --git a/docs/src/reference/hooks.md b/docs/src/reference/hooks.md index d69b8e60..89ce805c 100644 --- a/docs/src/reference/hooks.md +++ b/docs/src/reference/hooks.md @@ -279,7 +279,7 @@ Mutation functions can be sync or async. Provides a `#!python NamedTuple` containing `#!python async login` and `#!python async logout` functions. -This hook utilizes the Django's authentication framework in a way that provides **persistent** authentication across WebSocket and HTTP connections. +This hook utilizes the Django's authentication framework in a way that provides **persistent** login. === "components.py" @@ -307,7 +307,7 @@ This hook utilizes the Django's authentication framework in a way that provides ??? question "Why use this instead of `#!python channels.auth.login`?" - The `#!python channels.auth.*` functions cannot trigger re-renders of your ReactPy components. Additionally, it does not provide persistent authentication when used within ReactPy. + The `#!python channels.auth.*` functions cannot trigger re-renders of your ReactPy components. Additionally, they do not provide persistent authentication when used within ReactPy. Django's authentication design requires cookies to retain login status. ReactPy is rendered via WebSockets, and browsers do not allow active WebSocket connections to modify cookies. @@ -350,7 +350,7 @@ Shortcut that returns the WebSocket or HTTP connection's `#!python User`. ### Use User Data -Store or retrieve a `#!python dict` containing user data specific to the connection's `#!python User`. +Store or retrieve a `#!python dict` containing arbitrary data specific to the connection's `#!python User`. This hook is useful for storing user-specific data, such as preferences, settings, or any generic key-value pairs. diff --git a/src/reactpy_django/auth/components.py b/src/reactpy_django/auth/components.py index 28007a25..e0a1e065 100644 --- a/src/reactpy_django/auth/components.py +++ b/src/reactpy_django/auth/components.py @@ -103,8 +103,8 @@ async def synchronize_auth_callback(status_code: int, response: str): ) # If needed, synchronize authenication sessions by configuring all relevant session cookies. - # This is achieved by commanding the client to perform a HTTP request to our session manager endpoint, - # which will set any required cookies. + # This is achieved by commanding the client to perform a HTTP request to our API endpoint + # that will set any required cookies. if sync_needed: return HttpRequest( { diff --git a/src/reactpy_django/migrations/0007_authsession.py b/src/reactpy_django/migrations/0007_authtoken.py similarity index 69% rename from src/reactpy_django/migrations/0007_authsession.py rename to src/reactpy_django/migrations/0007_authtoken.py index b65322d1..49b06b0a 100644 --- a/src/reactpy_django/migrations/0007_authsession.py +++ b/src/reactpy_django/migrations/0007_authtoken.py @@ -1,4 +1,4 @@ -# Generated by Django 5.1.4 on 2024-12-23 04:36 +# Generated by Django 5.1.4 on 2024-12-29 07:44 from django.db import migrations, models @@ -11,9 +11,9 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='AuthSession', + name='AuthToken', fields=[ - ('uuid', models.UUIDField(editable=False, primary_key=True, serialize=False, unique=True)), + ('value', models.UUIDField(editable=False, primary_key=True, serialize=False, unique=True)), ('session_key', models.CharField(editable=False, max_length=40)), ('created_at', models.DateTimeField(auto_now_add=True)), ], diff --git a/src/reactpy_django/migrations/0008_rename_authsession_switchsession.py b/src/reactpy_django/migrations/0008_rename_authsession_switchsession.py deleted file mode 100644 index 125dd54e..00000000 --- a/src/reactpy_django/migrations/0008_rename_authsession_switchsession.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.4 on 2024-12-24 22:54 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('reactpy_django', '0007_authsession'), - ] - - operations = [ - migrations.RenameModel( - old_name='AuthSession', - new_name='SwitchSession', - ), - ] diff --git a/src/reactpy_django/migrations/0009_rename_switchsession_synchronizesession.py b/src/reactpy_django/migrations/0009_rename_switchsession_synchronizesession.py deleted file mode 100644 index b418aa00..00000000 --- a/src/reactpy_django/migrations/0009_rename_switchsession_synchronizesession.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 5.1.4 on 2024-12-25 00:18 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('reactpy_django', '0008_rename_authsession_switchsession'), - ] - - operations = [ - migrations.RenameModel( - old_name='SwitchSession', - new_name='SynchronizeSession', - ), - ] diff --git a/src/reactpy_django/migrations/0010_rename_synchronizesession_authtoken_and_more.py b/src/reactpy_django/migrations/0010_rename_synchronizesession_authtoken_and_more.py deleted file mode 100644 index b75f5024..00000000 --- a/src/reactpy_django/migrations/0010_rename_synchronizesession_authtoken_and_more.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 5.1.4 on 2024-12-25 05:52 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('reactpy_django', '0009_rename_switchsession_synchronizesession'), - ] - - operations = [ - migrations.RenameModel( - old_name='SynchronizeSession', - new_name='AuthToken', - ), - migrations.RenameField( - model_name='authtoken', - old_name='uuid', - new_name='value', - ), - ]