git://git.onelab.eu
/
myslice.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
omments on logging out
[myslice.git]
/
auth
/
backend.py
diff --git
a/auth/backend.py
b/auth/backend.py
index
a09ef60
..
4c93676
100644
(file)
--- a/
auth/backend.py
+++ b/
auth/backend.py
@@
-1,10
+1,6
@@
# import the User object
from django.contrib.auth.models import User
# import the User object
from django.contrib.auth.models import User
-# import the IMAP library
-#from imaplib import IMAP4
-
-# import time - this is used to create Django's internal username
import time
# Name my backend 'MyCustomBackend'
import time
# Name my backend 'MyCustomBackend'
@@
-18,7
+14,9
@@
class MyCustomBackend:
# Create an authentication method
# This is called by the standard Django login procedure
# Create an authentication method
# This is called by the standard Django login procedure
- def authenticate(self, username=None, password=None):
+ def authenticate(self, token=None):
+ username=token['username']
+ password=token['password']
users=MyCustomBackend.hard_wired_users
if username not in users: return None
if password != users[username]: return None
users=MyCustomBackend.hard_wired_users
if username not in users: return None
if password != users[username]: return None
@@
-26,8
+24,11
@@
class MyCustomBackend:
# Check if the user exists in Django's local database
user = User.objects.get(email=username)
except User.DoesNotExist:
# Check if the user exists in Django's local database
user = User.objects.get(email=username)
except User.DoesNotExist:
+ print 'creating django user',username
# Create a user in Django's local database
# Create a user in Django's local database
- user = User.objects.create_user(time.time(), username, 'passworddoesntmatter')
+ # warning: the trick here is pass current time as an id, and name as email
+ # create_user(username, email=None, password=None)
+ user = User.objects.create_user(time.time(), username, 'password-doesnt-matter')
return user
return user