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
fix haedwired users login
[myslice.git]
/
auth
/
manifoldbackend.py
diff --git
a/auth/manifoldbackend.py
b/auth/manifoldbackend.py
index
f548b43
..
54b16e7
100644
(file)
--- a/
auth/manifoldbackend.py
+++ b/
auth/manifoldbackend.py
@@
-11,39
+11,47
@@
class ManifoldBackend:
# 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):
- if not
username or not password
:
+ def authenticate(self,
token
=None):
+ if not
token
:
return None
try:
return None
try:
+ username = token['username']
+ password = token['password']
+ request = token['request']
+
auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
api = ManifoldAPI(auth)
# Authenticate user and get session key
session = api.GetSession()
if not session :
return None
auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
api = ManifoldAPI(auth)
# Authenticate user and get session key
session = api.GetSession()
if not session :
return None
-
+
#self.session = session
# Change GetSession() at some point to return expires as well
expires = time.time() + (24 * 60 * 60)
# Change to session authentication
api.auth = {'AuthMethod': 'session', 'session': session}
#self.session = session
# Change GetSession() at some point to return expires as well
expires = time.time() + (24 * 60 * 60)
# Change to session authentication
api.auth = {'AuthMethod': 'session', 'session': session}
-
#
self.api = api
+ self.api = api
# Get account details
# Get account details
- person = api.GetPersons(auth)
- #self.person = person[0]
+ person = api.GetPersons(auth)[0]
+ self.person = person
+
+ request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': expires}
except:
return None
try:
# Check if the user exists in Django's local database
except:
return None
try:
# Check if the user exists in Django's local database
- user = User.objects.get(
email
=username)
+ user = User.objects.get(
username
=username)
except User.DoesNotExist:
# Create a user in Django's local database
except User.DoesNotExist:
# Create a user in Django's local database
- user = User.objects.create_user(time.time(), username, 'passworddoesntmatter')
-
+ user = User.objects.create_user(username, username, 'passworddoesntmatter')
+ user.first_name = person['first_name']
+ user.last_name = person['last_name']
+ user.email = person['email']
return user
# Required for your backend to work properly - unchanged in most scenarios
return user
# Required for your backend to work properly - unchanged in most scenarios