X-Git-Url: https://git.mdrn.pl/fnpdjango.git/blobdiff_plain/0d15a2c208d18b3a79dfff5e9b361ea5776b696b..e7c406b88401d0d19aaa46bab8c24c01fb58455d:/fnpdjango/auth_backends.py?ds=inline diff --git a/fnpdjango/auth_backends.py b/fnpdjango/auth_backends.py index 3cd60a7..7a89c1a 100644 --- a/fnpdjango/auth_backends.py +++ b/fnpdjango/auth_backends.py @@ -10,13 +10,17 @@ attr_map = getattr(settings, 'CAS_USER_ATTRS_MAP', { class AttrCASBackend(CASBackend): def authenticate(self, ticket, service, request): user = super(AttrCASBackend, self).authenticate(ticket, service, request) + dirty = False for attr, value in request.session.get('attributes', {}).items(): try: local_attr = attr_map[attr] except KeyError: pass else: - setattr(user, local_attr, value) - user.save() + if getattr(user, local_attr, None) != value: + setattr(user, local_attr, value) + dirty = True + if dirty: + user.save() return user