Commit cfff3fe3 authored by Jérome Perrin's avatar Jérome Perrin

google login: use google mail address as login

No need to use a opaque user id. If we use mail address, to enable
google login for an existing user, we just have to "create google login
with email address and validate google login".
parent b2298bfc
......@@ -53,5 +53,5 @@ def getUserId(access_token):
socket.setdefaulttimeout(timeout)
if google_entry is not None:
return google_entry['id'].encode('utf-8')
return google_entry['email'].encode('utf-8')
return None
\ No newline at end of file
......@@ -163,7 +163,7 @@ class ERP5ExternalOauth2ExtractionPlugin:
except KeyError:
user_entry = self.getUserEntry(token)
if user_entry is not None:
user = user_entry["reference"] = user_dict["login"]
user = user_entry["reference"]
if user is None:
# fallback to default way
......@@ -263,14 +263,12 @@ class ERP5GoogleExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugin)
user_entry = {}
if google_entry is not None:
# sanitise value
try:
for k in (('first_name', 'given_name'),
for k in (('first_name', 'given_name'),
('last_name', 'family_name'),
('email', 'email')):
value = google_entry[k[1]].encode('utf-8')
user_entry[k[0]] = value
except KeyError:
user_entry = None
('email', 'email'),
('reference', 'email'),):
value = google_entry[k[1]].encode('utf-8')
user_entry[k[0]] = value
return user_entry
#List implementation of class
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment