Skip to content

Commit

Permalink
Load user model in backends
Browse files Browse the repository at this point in the history
Because django1.7 can't load user model in model they way it is loaded here.
  • Loading branch information
talebbits committed Aug 12, 2015
1 parent a8d9e4f commit 6d5474f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 9 additions & 3 deletions django_cas/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@

from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django_cas.models import User, Tgt, PgtIOU
from django_cas.models import Tgt, PgtIOU
from django_cas import CAS

__all__ = ['CASBackend']


try:
from django.contrib.auth import get_user_model
except ImportError:
from django.contrib.auth.models import User
else:
User = get_user_model()


def _verify_cas1(ticket, service):
"""Verifies CAS 1.0 authentication ticket.
Expand Down Expand Up @@ -108,7 +115,7 @@ def verify_proxy_ticket(ticket, service):
return None
finally:
page.close()


_PROTOCOLS = {'1': _verify_cas1, '2': _verify_cas2}

Expand Down Expand Up @@ -148,4 +155,3 @@ def get_user(self, user_id):
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None

8 changes: 1 addition & 7 deletions django_cas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
from django.db.models.signals import post_save
from datetime import datetime, timedelta
from django_cas import CAS
try:
from django.contrib.auth import get_user_model
except ImportError:
from django.contrib.auth.models import User
else:
User = get_user_model()


class Tgt(models.Model):
Expand Down Expand Up @@ -67,7 +61,7 @@ def get_tgt_for(user):
raise CasTicketException("no ticket found for user " + user.username)

def delete_old_tickets(**kwargs):
""" Delete tickets if they are over 2 days old
""" Delete tickets if they are over 2 days old
kwargs = ['raw', 'signal', 'instance', 'sender', 'created']
"""
sender = kwargs.get('sender', None)
Expand Down

0 comments on commit 6d5474f

Please sign in to comment.