Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
443509ca
Commit
443509ca
authored
9 months ago
by
Valentin Rigal
Committed by
Erwan Rouchet
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Update session data when updating the password with UpdateUser
parent
975b3f74
No related branches found
No related tags found
1 merge request
!2326
Update session data when updating the password with UpdateUser
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/users/serializers.py
+2
-0
2 additions, 0 deletions
arkindex/users/serializers.py
arkindex/users/tests/test_registration.py
+6
-0
6 additions, 0 deletions
arkindex/users/tests/test_registration.py
with
8 additions
and
0 deletions
arkindex/users/serializers.py
+
2
−
0
View file @
443509ca
from
django.conf
import
settings
from
django.contrib.auth
import
update_session_auth_hash
from
django.contrib.auth.password_validation
import
validate_password
from
django.contrib.auth.tokens
import
default_token_generator
from
django.core.exceptions
import
ValidationError
...
...
@@ -66,6 +67,7 @@ class UserSerializer(SimpleUserSerializer):
def
update
(
self
,
instance
,
validated_data
):
if
"
password
"
in
validated_data
:
instance
.
set_password
(
validated_data
.
pop
(
"
password
"
))
update_session_auth_hash
(
self
.
context
[
"
request
"
],
instance
)
return
super
().
update
(
instance
,
validated_data
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/users/tests/test_registration.py
+
6
−
0
View file @
443509ca
...
...
@@ -57,6 +57,12 @@ class TestRegistration(FixtureAPITestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
user
.
refresh_from_db
()
self
.
assertTrue
(
self
.
user
.
check_password
(
"
N€wP4$5w0Rd
"
))
# Ensure client session is still valid
response
=
self
.
client
.
get
(
reverse
(
"
api:user-retrieve
"
),
format
=
"
json
"
,
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
def
test_update_display_name
(
self
):
self
.
client
.
force_login
(
self
.
user
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment