From b1ce2197cbe0986866467c7306d67fbe2dfe8b36 Mon Sep 17 00:00:00 2001
From: Valentin Rigal <rigal@teklia.com>
Date: Tue, 28 May 2024 16:10:22 +0200
Subject: [PATCH] Update session data when updating the password with
 UpdateUser

---
 arkindex/users/serializers.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arkindex/users/serializers.py b/arkindex/users/serializers.py
index d30ba1c369..6120accad4 100644
--- a/arkindex/users/serializers.py
+++ b/arkindex/users/serializers.py
@@ -1,4 +1,5 @@
 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)
 
 
-- 
GitLab