From 6ed7eb5a06d16a3a761f4c6c99b9fc78ed4027d5 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Fri, 6 Jun 2014 12:21:31 +0530 Subject: README file added to the authentication app. --- testapp/myauthentication/backend.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'testapp/myauthentication/backend.py') diff --git a/testapp/myauthentication/backend.py b/testapp/myauthentication/backend.py index 35dcfeb..698ec54 100644 --- a/testapp/myauthentication/backend.py +++ b/testapp/myauthentication/backend.py @@ -8,23 +8,28 @@ class MyBackend: 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 detail in django User table + and authenticates user. + ''' try: user = MdlUser.objects.get(username=username) pwd = user.password uid = user.id firstname = user.firstname lastname = user.lastname - email = user.email + email_id = user.email p = hashlib.md5(password) pwd_valid = (pwd == p.hexdigest()) if user and pwd_valid: try: - print "here" user = User.objects.get(username=username) - print "hh" return user except Exception, e: - user=User(id=uid, username=username, password=pwd, first_name=firstname, last_name=lastname, email=email) + user=User(id=uid, username=username, password=pwd,\ + first_name=firstname, last_name=lastname,\ + email=email_id) user.save() return user except Exception, e: -- cgit