Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
7b515720 by Cédric Krier at 2023-03-07T16:33:58+01:00
Remove password hash also from the transaction cache

Closes #12120
- - - - -


1 changed file:

- trytond/trytond/res/user.py


Changes:

=====================================
trytond/trytond/res/user.py
=====================================
@@ -364,6 +364,7 @@
     @classmethod
     def read(cls, ids, fields_names):
         result = super(User, cls).read(ids, fields_names)
-        if not fields_names or 'password_hash' in fields_names:
-            for values in result:
+        cache = Transaction().get_cache()[cls.__name__]
+        for values in result:
+            if 'password_hash' in values:
                 values['password_hash'] = None
@@ -369,4 +370,6 @@
                 values['password_hash'] = None
+            if values['id'] in cache:
+                cache[values['id']]['password_hash'] = None
         return result
 
     @classmethod
@@ -370,6 +373,20 @@
         return result
 
     @classmethod
+    def search(
+            cls, domain, offset=0, limit=None, order=None, count=False,
+            query=False):
+        users = super().search(
+            domain, offset=offset, limit=limit, order=order, count=count,
+            query=query)
+        cache = Transaction().get_cache()[cls.__name__]
+        if not count and not query:
+            for user in users:
+                if user.id in cache:
+                    cache[user.id]['password_hash'] = None
+        return users
+
+    @classmethod
     def create(cls, vlist):
         vlist = [cls._convert_vals(vals) for vals in vlist]
         return super(User, cls).create(vlist)



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/7b5157206d328bfe020fabece59fb7747dd2dd9d

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/7b5157206d328bfe020fabece59fb7747dd2dd9d
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to