plain.auth 0.20.0__tar.gz → 0.20.1__tar.gz
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-0.20.0 → plain_auth-0.20.1}/PKG-INFO +17 -13
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/CHANGELOG.md +10 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/README.md +16 -12
- {plain_auth-0.20.0 → plain_auth-0.20.1}/pyproject.toml +1 -1
- {plain_auth-0.20.0 → plain_auth-0.20.1}/.gitignore +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/LICENSE +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/README.md +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/__init__.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/default_settings.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/requests.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/sessions.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/templates.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/test.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/utils.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/plain/auth/views.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/tests/app/settings.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/tests/app/urls.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/tests/app/users/migrations/0001_initial.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/tests/app/users/migrations/__init__.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/tests/app/users/models.py +0 -0
- {plain_auth-0.20.0 → plain_auth-0.20.1}/tests/test_views.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: plain.auth
|
|
3
|
-
Version: 0.20.
|
|
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
|
-
|
|
33
|
-
|
|
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.
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
In templates:
|
|
126
|
+
In templates, use the `get_current_user()` function:
|
|
126
127
|
|
|
127
128
|
```html
|
|
128
|
-
{% if
|
|
129
|
-
<p>Hello, {{
|
|
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
|
-
|
|
139
|
-
|
|
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.
|
|
170
|
+
if not self.user.is_special:
|
|
167
171
|
raise PermissionDenied("You're not special!")
|
|
168
172
|
```
|
|
169
173
|
|
|
@@ -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
|
|
@@ -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
|
-
|
|
21
|
-
|
|
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.
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
In templates:
|
|
114
|
+
In templates, use the `get_current_user()` function:
|
|
114
115
|
|
|
115
116
|
```html
|
|
116
|
-
{% if
|
|
117
|
-
<p>Hello, {{
|
|
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
|
-
|
|
127
|
-
|
|
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.
|
|
158
|
+
if not self.user.is_special:
|
|
155
159
|
raise PermissionDenied("You're not special!")
|
|
156
160
|
```
|
|
157
161
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|