Revision e5966bd9 snf-astakos-app/astakos/im/auth_backends.py
b/snf-astakos-app/astakos/im/auth_backends.py | ||
---|---|---|
47 | 47 |
""" |
48 | 48 |
def authenticate(self, email=None, auth_token=None): |
49 | 49 |
try: |
50 |
user = AstakosUser.objects.get(email__iexact=email, is_active=True)
|
|
51 |
if user.auth_token == auth_token:
|
|
52 |
return user
|
|
50 |
user = AstakosUser.objects.get_by_identifier(email, is_active=True,
|
|
51 |
auth_token=auth_token)
|
|
52 |
return user |
|
53 | 53 |
except AstakosUser.DoesNotExist: |
54 | 54 |
return None |
55 | 55 |
else: |
... | ... | |
72 | 72 |
""" |
73 | 73 |
def authenticate(self, username=None, password=None): |
74 | 74 |
# First check whether a user having this email exists |
75 |
users = AstakosUser.objects.filter(email__iexact=username) |
|
76 |
for user in users: |
|
75 |
try: |
|
76 |
user = AstakosUser.objects.get_by_identifier(username, |
|
77 |
is_active=True) |
|
77 | 78 |
if user.check_password(password): |
78 | 79 |
return user |
79 |
|
|
80 |
# Since no user has been found by email try with the username |
|
81 |
try: |
|
82 |
user = AstakosUser.objects.get(username=username) |
|
83 | 80 |
except AstakosUser.DoesNotExist: |
84 | 81 |
return None |
85 |
|
|
82 |
|
|
86 | 83 |
if user.check_password(password): |
87 | 84 |
return user |
88 | 85 |
else: |
Also available in: Unified diff