plain.auth 0.20.0__py3-none-any.whl → 0.20.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
plain/auth/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # plain-auth changelog
2
2
 
3
+ ## [0.20.1](https://github.com/dropseed/plain/releases/plain-auth@0.20.1) (2025-10-02)
4
+
5
+ ### What's changed
6
+
7
+ - Updated README documentation to use `get_request_user()` and `get_current_user()` instead of `request.user` ([f6278d9](https://github.com/dropseed/plain/commit/f6278d9bb4))
8
+
9
+ ### Upgrade instructions
10
+
11
+ - No changes required
12
+
3
13
  ## [0.20.0](https://github.com/dropseed/plain/releases/plain-auth@0.20.0) (2025-10-02)
4
14
 
5
15
  ### What's changed
plain/auth/README.md CHANGED
@@ -17,8 +17,11 @@ The `plain.auth` package provides user authentication and authorization for Plai
17
17
 
18
18
  ```python
19
19
  # In a view
20
- if request.user:
21
- print(f"Hello, {request.user.email}!")
20
+ from plain.auth import get_request_user
21
+
22
+ user = get_request_user(request)
23
+ if user:
24
+ print(f"Hello, {user.email}!")
22
25
  else:
23
26
  print("You are not logged in.")
24
27
  ```
@@ -33,7 +36,7 @@ class ProfileView(AuthViewMixin, View):
33
36
  login_required = True
34
37
 
35
38
  def get(self):
36
- return f"Welcome, {self.request.user.email}!"
39
+ return f"Welcome, {self.user.email}!"
37
40
  ```
38
41
 
39
42
  ## Authentication setup
@@ -108,23 +111,24 @@ urlpatterns = [
108
111
 
109
112
  ## Checking if a user is logged in
110
113
 
111
- A `request.user` will either be `None` or point to an instance of your `AUTH_USER_MODEL`.
112
-
113
- In templates:
114
+ In templates, use the `get_current_user()` function:
114
115
 
115
116
  ```html
116
- {% if request.user %}
117
- <p>Hello, {{ request.user.email }}!</p>
117
+ {% if get_current_user() %}
118
+ <p>Hello, {{ get_current_user().email }}!</p>
118
119
  {% else %}
119
120
  <p>You are not logged in.</p>
120
121
  {% endif %}
121
122
  ```
122
123
 
123
- In Python code:
124
+ In Python code, use `get_request_user()`:
124
125
 
125
126
  ```python
126
- if request.user:
127
- print(f"Hello, {request.user.email}!")
127
+ from plain.auth import get_request_user
128
+
129
+ user = get_request_user(request)
130
+ if user:
131
+ print(f"Hello, {user.email}!")
128
132
  else:
129
133
  print("You are not logged in.")
130
134
  ```
@@ -151,7 +155,7 @@ class AdminOnlyView(AuthViewMixin, View):
151
155
  class CustomPermissionView(AuthViewMixin, View):
152
156
  def check_auth(self):
153
157
  super().check_auth()
154
- if not self.request.user.is_special:
158
+ if not self.user.is_special:
155
159
  raise PermissionDenied("You're not special!")
156
160
  ```
157
161
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plain.auth
3
- Version: 0.20.0
3
+ Version: 0.20.1
4
4
  Summary: Add users to your app and decide what they can access.
5
5
  Author-email: Dave Gaeddert <dave.gaeddert@dropseed.dev>
6
6
  License-File: LICENSE
@@ -29,8 +29,11 @@ The `plain.auth` package provides user authentication and authorization for Plai
29
29
 
30
30
  ```python
31
31
  # In a view
32
- if request.user:
33
- print(f"Hello, {request.user.email}!")
32
+ from plain.auth import get_request_user
33
+
34
+ user = get_request_user(request)
35
+ if user:
36
+ print(f"Hello, {user.email}!")
34
37
  else:
35
38
  print("You are not logged in.")
36
39
  ```
@@ -45,7 +48,7 @@ class ProfileView(AuthViewMixin, View):
45
48
  login_required = True
46
49
 
47
50
  def get(self):
48
- return f"Welcome, {self.request.user.email}!"
51
+ return f"Welcome, {self.user.email}!"
49
52
  ```
50
53
 
51
54
  ## Authentication setup
@@ -120,23 +123,24 @@ urlpatterns = [
120
123
 
121
124
  ## Checking if a user is logged in
122
125
 
123
- A `request.user` will either be `None` or point to an instance of your `AUTH_USER_MODEL`.
124
-
125
- In templates:
126
+ In templates, use the `get_current_user()` function:
126
127
 
127
128
  ```html
128
- {% if request.user %}
129
- <p>Hello, {{ request.user.email }}!</p>
129
+ {% if get_current_user() %}
130
+ <p>Hello, {{ get_current_user().email }}!</p>
130
131
  {% else %}
131
132
  <p>You are not logged in.</p>
132
133
  {% endif %}
133
134
  ```
134
135
 
135
- In Python code:
136
+ In Python code, use `get_request_user()`:
136
137
 
137
138
  ```python
138
- if request.user:
139
- print(f"Hello, {request.user.email}!")
139
+ from plain.auth import get_request_user
140
+
141
+ user = get_request_user(request)
142
+ if user:
143
+ print(f"Hello, {user.email}!")
140
144
  else:
141
145
  print("You are not logged in.")
142
146
  ```
@@ -163,7 +167,7 @@ class AdminOnlyView(AuthViewMixin, View):
163
167
  class CustomPermissionView(AuthViewMixin, View):
164
168
  def check_auth(self):
165
169
  super().check_auth()
166
- if not self.request.user.is_special:
170
+ if not self.user.is_special:
167
171
  raise PermissionDenied("You're not special!")
168
172
  ```
169
173
 
@@ -1,5 +1,5 @@
1
- plain/auth/CHANGELOG.md,sha256=IyxuPyEHvnwqEu6GKtUEOtlu1iuLg5Xux6610lrRAIU,4200
2
- plain/auth/README.md,sha256=Kr3pW6XDd9sp-b8DOH2uKRqCqrR8MYB98qRUxeiwn0k,3944
1
+ plain/auth/CHANGELOG.md,sha256=W74wFZKot-9heq8l_MsoLSDmHLdAe5LSo9qFPliXFS0,4533
2
+ plain/auth/README.md,sha256=I1SeOyrBnF0GAjD7T0k5OlZ2bSHz9---nElinaobewc,4030
3
3
  plain/auth/__init__.py,sha256=CrOsS74CPGN1nPTTfie13mPgdyVLRyZ1YwDPIA77uaA,179
4
4
  plain/auth/default_settings.py,sha256=65VzDn3j61OMn78Lg6Zuds4A8QKzJJ_0G9KoFqAOIRo,466
5
5
  plain/auth/requests.py,sha256=f8QUpqHueoTYnL2ITgRXxLFYLSxra9jW3p9pjFgj0B0,949
@@ -8,7 +8,7 @@ plain/auth/templates.py,sha256=MQ9vdxE2fBXN-F043g8EGm93s6HRvEMtGHrFcbAr3Fs,400
8
8
  plain/auth/test.py,sha256=bLxQEp1mM4t9b-bSSq2u9_Z07Wkl--7U_mSBb9VV7BU,1428
9
9
  plain/auth/utils.py,sha256=eEON0Mo928l-aW5tqBuoTdVke8aP4majxVtAFoLroSE,1280
10
10
  plain/auth/views.py,sha256=Gm91sB_Z47h-8SwxCMKVKl57FSjed_AM5fdeaiPmz-E,4761
11
- plain_auth-0.20.0.dist-info/METADATA,sha256=9LQj-14o1wKsAbKp3xTd09vmjuJTzYvcD4xjiUqGRqY,4304
12
- plain_auth-0.20.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- plain_auth-0.20.0.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
14
- plain_auth-0.20.0.dist-info/RECORD,,
11
+ plain_auth-0.20.1.dist-info/METADATA,sha256=5E0uGbf7uFA-F0ywFO45xQOLQSCbvYw9nSNVyezRITI,4390
12
+ plain_auth-0.20.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ plain_auth-0.20.1.dist-info/licenses/LICENSE,sha256=m0D5O7QoH9l5Vz_rrX_9r-C8d9UNr_ciK6Qwac7o6yo,3175
14
+ plain_auth-0.20.1.dist-info/RECORD,,