summaryrefslogtreecommitdiff
path: root/testapp/myauthentication/backend.py
diff options
context:
space:
mode:
authorankitjavalkar2015-09-14 12:28:41 +0530
committerankitjavalkar2015-09-15 11:33:59 +0530
commit7a60f782995eed0352f3172f445bb35ae8ee6aa9 (patch)
tree91d6d12b0a494dd9777fd1120e92db5763bf009a /testapp/myauthentication/backend.py
parent32cde26f9807a29eb1fae0833e353212d43d7802 (diff)
downloadonline_test-7a60f782995eed0352f3172f445bb35ae8ee6aa9.tar.gz
online_test-7a60f782995eed0352f3172f445bb35ae8ee6aa9.tar.bz2
online_test-7a60f782995eed0352f3172f445bb35ae8ee6aa9.zip
Remove testapp dir, remove reference to testapp in paths, files
Diffstat (limited to 'testapp/myauthentication/backend.py')
-rw-r--r--testapp/myauthentication/backend.py43
1 files changed, 0 insertions, 43 deletions
diff --git a/testapp/myauthentication/backend.py b/testapp/myauthentication/backend.py
deleted file mode 100644
index 721fe54..0000000
--- a/testapp/myauthentication/backend.py
+++ /dev/null
@@ -1,43 +0,0 @@
-import hashlib
-from django.contrib.auth.models import User, check_password
-from models_spoken_tutorial import MoodleUser
-
-
-class MyBackend:
- supports_object_permissions = False
- supports_anonymous_user = False
- supports_inactive_user = False
-
- def authenticate(self, username=None, password=None):
- '''
- Checks username and password with external User table.
- If valid then adds the user details in django User table
- and authenticates the user.
- '''
- try:
- 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())
- 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
- except Exception, e:
- return None
-
- def get_user(self, user_id):
- try:
- return User.objects.get(pk=user_id)
- except Exception, e:
- return None