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


Commits:
2c557f1b by Cédric Krier at 2023-03-30T22:36:18+02:00
Do not fails to clear password from cache if there is no cache

This was introduced in 7b5157206d32

Closes #12165
- - - - -


1 changed file:

- trytond/trytond/res/user.py


Changes:

=====================================
trytond/trytond/res/user.py
=====================================
@@ -364,12 +364,13 @@
     @classmethod
     def read(cls, ids, fields_names):
         result = super(User, cls).read(ids, fields_names)
-        cache = Transaction().get_cache()[cls.__name__]
-        for values in result:
-            if 'password_hash' in values:
-                values['password_hash'] = None
-            if values['id'] in cache:
-                cache[values['id']]['password_hash'] = None
+        cache = Transaction().get_cache().get(cls.__name__)
+        if cache is not None:
+            for values in result:
+                if 'password_hash' in values:
+                    values['password_hash'] = None
+                if values['id'] in cache:
+                    cache[values['id']]['password_hash'] = None
         return result
 
     @classmethod
@@ -379,5 +380,4 @@
         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:
@@ -383,7 +383,9 @@
         if not count and not query:
-            for user in users:
-                if user.id in cache:
-                    cache[user.id]['password_hash'] = None
+            cache = Transaction().get_cache().get(cls.__name__)
+            if cache is not None:
+                for user in users:
+                    if user.id in cache:
+                        cache[user.id]['password_hash'] = None
         return users
 
     @classmethod



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/2c557f1b4882006ec487e11f4e0b8aed1ef37860

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


Reply via email to