Commit 40c6a3e4 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 fa6d213a
...@@ -53,5 +53,5 @@ def getUserId(access_token): ...@@ -53,5 +53,5 @@ def getUserId(access_token):
socket.setdefaulttimeout(timeout) socket.setdefaulttimeout(timeout)
if google_entry is not None: if google_entry is not None:
return google_entry['id'].encode('utf-8') return google_entry['email'].encode('utf-8')
return None return None
\ No newline at end of file
...@@ -163,7 +163,7 @@ class ERP5ExternalOauth2ExtractionPlugin: ...@@ -163,7 +163,7 @@ class ERP5ExternalOauth2ExtractionPlugin:
except KeyError: except KeyError:
user_entry = self.getUserEntry(token) user_entry = self.getUserEntry(token)
if user_entry is not None: if user_entry is not None:
user = user_entry["reference"] = user_dict["login"] user = user_entry["reference"]
if user is None: if user is None:
# fallback to default way # fallback to default way
...@@ -263,14 +263,12 @@ class ERP5GoogleExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugin) ...@@ -263,14 +263,12 @@ class ERP5GoogleExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugin)
user_entry = {} user_entry = {}
if google_entry is not None: if google_entry is not None:
# sanitise value # sanitise value
try: for k in (('first_name', 'given_name'),
for k in (('first_name', 'given_name'),
('last_name', 'family_name'), ('last_name', 'family_name'),
('email', 'email')): ('email', 'email'),
value = google_entry[k[1]].encode('utf-8') ('reference', 'email'),):
user_entry[k[0]] = value value = google_entry[k[1]].encode('utf-8')
except KeyError: user_entry[k[0]] = value
user_entry = None
return user_entry return user_entry
#List implementation of class #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