X-Git-Url: https://git.mdrn.pl/fnpdjango.git/blobdiff_plain/28b1d7e9f4a7008712736adce363ca2770d48aea..c4311d82afc1bb44566c6e612b09c4ecad1af643:/fnpdjango/auth_backends.py diff --git a/fnpdjango/auth_backends.py b/fnpdjango/auth_backends.py deleted file mode 100644 index 7a89c1a..0000000 --- a/fnpdjango/auth_backends.py +++ /dev/null @@ -1,26 +0,0 @@ -from django.conf import settings -from django_cas.backends import CASBackend - -attr_map = getattr(settings, 'CAS_USER_ATTRS_MAP', { - 'email': 'email', - 'firstname': 'first_name', - 'lastname': 'last_name', -}) - -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: - if getattr(user, local_attr, None) != value: - setattr(user, local_attr, value) - dirty = True - if dirty: - user.save() - return user -