Commit 86242ed1 authored by Jérome Perrin's avatar Jérome Perrin

panel: drop custom ERP5Site_receiveGoogleCallback

See merge request !642
parents 67131c0a 84d44095
...@@ -290,7 +290,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -290,7 +290,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_parameter_editor/SoftwareProductModule_validateParameterEditorTestDialog', 'slapos_parameter_editor/SoftwareProductModule_validateParameterEditorTestDialog',
'slapos_parameter_editor/SoftwareProductModule_validateSoftwareReleaseForParameterEditorTestDialog', 'slapos_parameter_editor/SoftwareProductModule_validateSoftwareReleaseForParameterEditorTestDialog',
'slapos_web_renderjs_ui/ERP5Site_callbackFacebookLogin', 'slapos_web_renderjs_ui/ERP5Site_callbackFacebookLogin',
'slapos_web_renderjs_ui/ERP5Site_receiveGoogleCallback',
'slapos_web_renderjs_ui/PasswordTool_changeUserPassword', 'slapos_web_renderjs_ui/PasswordTool_changeUserPassword',
'slapos_web_renderjs_ui/WebSection_getDocumentValue', 'slapos_web_renderjs_ui/WebSection_getDocumentValue',
'slapos_web_renderjs_ui/WebSection_getLoginWarningMessage', 'slapos_web_renderjs_ui/WebSection_getLoginWarningMessage',
......
import time
def handleError(error):
context.Base_redirect(
'login_form',
keep_items={"portal_status_message":
context.Base_translateString(
"There was problem with Google login: ${error}. Please try again later.",
mapping={"error": error})
})
if error is not None:
return handleError(error)
elif code is not None:
response_dict = context.ERP5Site_getAccessTokenFromCode(
code,
"{0}/ERP5Site_receiveGoogleCallback".format(context.absolute_url()))
if response_dict is not None:
access_token = response_dict['access_token'].encode('utf-8')
hash_str = context.Base_getHMAC(access_token, access_token)
response = context.REQUEST.RESPONSE
context.setAuthCookie(response, '__ac_google_hash', hash_str)
# store timestamp in second since the epoch in UTC is enough
response_dict["response_timestamp"] = time.time()
context.Base_setBearerToken(hash_str,
response_dict,
"google_server_auth_token_cache_factory")
user_dict = context.ERP5Site_getGoogleUserEntry(access_token)
user_reference = user_dict["email"]
context.Base_setBearerToken(access_token,
{"reference": user_reference},
"google_server_auth_token_cache_factory")
method = getattr(context, "ERP5Site_createGoogleUserToOAuth", None)
if method is not None:
method(user_reference, user_dict)
person_relative_url = context.ERP5Site_getPersonFromGoogleLogin(user_reference)
came_from = context.absolute_url() + "/#!login?n.me=%s" % person_relative_url
response.setHeader('Location', came_from)
response.setStatus(303)
else:
return handleError('')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>code=None, error=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_receiveGoogleCallback</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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