diff options
author | prathamesh | 2014-06-09 10:30:22 +0530 |
---|---|---|
committer | prathamesh | 2014-06-09 10:30:22 +0530 |
commit | 5adb38569bec47ea0a1ea63e22ceec8906717b04 (patch) | |
tree | af75e47255f39402c79ded6f75399a47084584ff /testapp/myauthentication/backend.py | |
parent | 7d0753f2e0f590ed4376fdb5f8abaace7c4cfc19 (diff) | |
parent | e50eb8426d5f22fd35a2575cd3f4617226bc1a01 (diff) | |
download | online_test-5adb38569bec47ea0a1ea63e22ceec8906717b04.tar.gz online_test-5adb38569bec47ea0a1ea63e22ceec8906717b04.tar.bz2 online_test-5adb38569bec47ea0a1ea63e22ceec8906717b04.zip |
Merge branch 'master' of https://github.com/FOSSEE/online_test
Diffstat (limited to 'testapp/myauthentication/backend.py')
-rw-r--r-- | testapp/myauthentication/backend.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/testapp/myauthentication/backend.py b/testapp/myauthentication/backend.py index d82f11a..721fe54 100644 --- a/testapp/myauthentication/backend.py +++ b/testapp/myauthentication/backend.py @@ -1,6 +1,7 @@ import hashlib from django.contrib.auth.models import User, check_password -from models_spoken import MdlUser +from models_spoken_tutorial import MoodleUser + class MyBackend: supports_object_permissions = False @@ -14,24 +15,24 @@ class MyBackend: and authenticates the user. ''' try: - user = MdlUser.objects.get(username=username) + user = MoodleUser.objects.get(username=username) pwd = user.password uid = user.id firstname = user.firstname lastname = user.lastname email_id = user.email p = hashlib.md5(password) - pwd_valid = (pwd == p.hexdigest()) + pwd_valid = (pwd == p.hexdigest()) if user and pwd_valid: - try: - user = User.objects.get(username=username) - return user - except Exception, e: - user=User(id=uid, username=username, password=pwd,\ - first_name=firstname, last_name=lastname,\ - email=email_id) - user.save() - return user + try: + user = User.objects.get(username=username) + return user + except Exception, e: + user = User(id=uid, username=username, password=pwd, + first_name=firstname, last_name=lastname, + email=email_id) + user.save() + return user except Exception, e: return None |