You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added `REACTPY_AUTH_BACKEND` setting to allow for custom authentication backends.
- Refactor the websocket consumer so that using `SessionMiddlewareStack` and/or `AuthMiddlewareStack` is now optional.
- Make Django a mandatory project dependency, since we need Django 4.1+
Copy file name to clipboardExpand all lines: docs/src/features/decorators.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
You can limit access to a component to users with a specific `auth_attribute` by using this decorator (with or without parentheses).
10
10
11
-
By default, this decorator checks if the user is logged in, and his/her account has not been deactivated.
11
+
By default, this decorator checks if the user is logged in and not deactivated (`is_active`).
12
12
13
13
This decorator is commonly used to selectively render a component only if a user [`is_staff`](https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.is_staff) or [`is_superuser`](https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.is_superuser).
Copy file name to clipboardExpand all lines: docs/src/get-started/installation.md
+21-3
Original file line number
Diff line number
Diff line change
@@ -28,21 +28,25 @@ In your settings you will need to add `reactpy_django` to [`INSTALLED_APPS`](htt
28
28
29
29
ReactPy-Django requires ASGI Websockets from [Django Channels](https://github.com/django/channels).
30
30
31
-
If you have not enabled ASGI on your **Django project** yet, you will need to install `channels[daphne]`, add `daphne` to `INSTALLED_APPS`, then set your `ASGI_APPLICATION` variable.
31
+
If you have not enabled ASGI on your **Django project** yet, you will need to
32
32
33
-
Read the [Django Channels Docs](https://channels.readthedocs.io/en/stable/installation.html) for more info.
33
+
1. Install `channels[daphne]`
34
+
2. Add `daphne` to `INSTALLED_APPS`
35
+
3. Set your `ASGI_APPLICATION` variable.
34
36
35
37
=== "settings.py"
36
38
37
39
```python
38
40
{% include "../../python/configure-channels.py" %}
39
41
```
40
42
43
+
Consider reading the [Django Channels Docs](https://channels.readthedocs.io/en/stable/installation.html) for more info.
44
+
41
45
??? note "Configure ReactPy settings (Optional)"
42
46
43
47
Below are a handful of values you can change within `settings.py` to modify the behavior of ReactPy.
44
48
45
-
```python
49
+
```python linenums="0"
46
50
{% include "../../python/settings.py" %}
47
51
```
48
52
@@ -66,6 +70,20 @@ Register ReactPy's Websocket using `REACTPY_WEBSOCKET_PATH`.
66
70
{% include "../../python/configure-asgi.py" %}
67
71
```
68
72
73
+
??? note "Add `AuthMiddlewareStack` and `SessionMiddlewareStack` (Optional)"
74
+
75
+
There are many situations where you need to access the Django `User` or `Session` objects within ReactPy components. For example, if you want to:
76
+
77
+
1. Access the `User` that is currently logged in
78
+
2. Login or logout the current `User`
79
+
3. Access Django's `Sesssion` object
80
+
81
+
In these situations will need to ensure you are using `AuthMiddlewareStack` and/or `SessionMiddlewareStack`.
82
+
83
+
```python linenums="0"
84
+
{% include "../../python/configure-asgi-middleware.py" start="# start" %}
85
+
```
86
+
69
87
??? question "Where is my `asgi.py`?"
70
88
71
89
If you do not have an `asgi.py`, follow the [`channels` installation guide](https://channels.readthedocs.io/en/stable/installation.html).
0 commit comments