Commit fa097411 authored by Gabriel Monnerat's avatar Gabriel Monnerat Committed by Jérome Perrin

erp5_oauth_google_login: s/erp5_username/user_id/g to be with consistent with...

erp5_oauth_google_login: s/erp5_username/user_id/g to be with consistent with Base_getUserValueByUserId
parent 2f9b4936
...@@ -20,7 +20,7 @@ activate_kw = {'tag': tag} ...@@ -20,7 +20,7 @@ activate_kw = {'tag': tag}
# to support Facebook login # to support Facebook login
assert login_portal_type in ("Google Login",), "Impossible to select a portal type" assert login_portal_type in ("Google Login",), "Impossible to select a portal type"
if erp5_username in ("Anonymous User", None): if user_id in ("Anonymous User", None):
person = portal.person_module.newContent(portal_type='Person', person = portal.person_module.newContent(portal_type='Person',
user_id=reference, user_id=reference,
first_name=first_name, first_name=first_name,
...@@ -50,7 +50,7 @@ if erp5_username in ("Anonymous User", None): ...@@ -50,7 +50,7 @@ if erp5_username in ("Anonymous User", None):
assignment.open(activate_kw=activate_kw) assignment.open(activate_kw=activate_kw)
person.setDefaultCareerRoleList(assignment.getRoleList()) person.setDefaultCareerRoleList(assignment.getRoleList())
else: else:
person = context.Base_getUserValueByUserId(erp5_username) person = context.Base_getUserValueByUserId(user_id)
login = person.newContent(portal_type=login_portal_type, login = person.newContent(portal_type=login_portal_type,
reference=reference) reference=reference)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>tag, first_name, last_name, reference, email, login_portal_type, erp5_username=None</string> </value> <value> <string>tag, first_name, last_name, reference, email, login_portal_type, user_id=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -20,7 +20,7 @@ elif code is not None: ...@@ -20,7 +20,7 @@ elif code is not None:
if response_dict is not None: if response_dict is not None:
access_token = response_dict['access_token'].encode('utf-8') access_token = response_dict['access_token'].encode('utf-8')
response_dict['login'] = context.ERP5Site_getGoogleUserId(access_token) response_dict['login'] = context.ERP5Site_getGoogleUserId(access_token)
response_dict['erp5_username'] = portal.portal_membership.getAuthenticatedMember().getUserName() response_dict['user_id'] = portal.portal_membership.getAuthenticatedMember().getUserName()
hash_str = context.Base_getHMAC(access_token, access_token) hash_str = context.Base_getHMAC(access_token, access_token)
context.REQUEST.RESPONSE.setCookie('__ac_google_hash', hash_str, path='/') context.REQUEST.RESPONSE.setCookie('__ac_google_hash', hash_str, path='/')
context.Base_setBearerToken(hash_str, context.Base_setBearerToken(hash_str,
......
...@@ -142,7 +142,7 @@ class TestGoogleLogin(ERP5TypeTestCase): ...@@ -142,7 +142,7 @@ class TestGoogleLogin(ERP5TypeTestCase):
"reference": user_id, "reference": user_id,
"email": 'example@email.com', "email": 'example@email.com',
"login_portal_type": "Google Login", "login_portal_type": "Google Login",
"erp5_username": self.dummy_user_id "user_id": self.dummy_user_id
} }
# We are using superuser to avoid Unauthorized error # We are using superuser to avoid Unauthorized error
# The goal of this test to check if Google Login is created # The goal of this test to check if Google Login is created
...@@ -164,7 +164,7 @@ class TestGoogleLogin(ERP5TypeTestCase): ...@@ -164,7 +164,7 @@ class TestGoogleLogin(ERP5TypeTestCase):
"reference": user_id, "reference": user_id,
"email": 'example@email.com', "email": 'example@email.com',
"login_portal_type": "Google Login", "login_portal_type": "Google Login",
"erp5_username": 'Anonymous User' "user_id": 'Anonymous User'
} }
self.portal.Base_createOauth2User(**user_entry) self.portal.Base_createOauth2User(**user_entry)
self.tic() self.tic()
......
...@@ -189,9 +189,9 @@ class ERP5ExternalOauth2ExtractionPlugin: ...@@ -189,9 +189,9 @@ class ERP5ExternalOauth2ExtractionPlugin:
try: try:
self.REQUEST['USER_CREATION_IN_PROGRESS'] = user_dict self.REQUEST['USER_CREATION_IN_PROGRESS'] = user_dict
user_entry["login_portal_type"] = creds["login_portal_type"] user_entry["login_portal_type"] = creds["login_portal_type"]
# erp5_username is optional. # user_id is optional.
# It is only used to create Google Login under a pre-existing person # It is only used to create Google Login under a pre-existing person
user_entry["erp5_username"] = user_dict.get("erp5_username") user_entry["user_id"] = user_dict.get("user_id")
try: try:
Base_createOauth2User(tag, **user_entry) Base_createOauth2User(tag, **user_entry)
except Exception: except Exception:
......
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