Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.core
Commits
e04ac901
Commit
e04ac901
authored
Feb 20, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_jio: Customize callback from Facebook/Google to work with renderjs.
parent
671ffbbf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
214 additions
and
0 deletions
+214
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_callbackFacebookLogin.py
...s/slapos_hal_json_style/ERP5Site_callbackFacebookLogin.py
+43
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_callbackFacebookLogin.xml
.../slapos_hal_json_style/ERP5Site_callbackFacebookLogin.xml
+70
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_receiveGoogleCallback.py
...s/slapos_hal_json_style/ERP5Site_receiveGoogleCallback.py
+39
-0
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_receiveGoogleCallback.xml
.../slapos_hal_json_style/ERP5Site_receiveGoogleCallback.xml
+62
-0
No files found.
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_callbackFacebookLogin.py
0 → 100644
View file @
e04ac901
import
time
def
handleError
(
error
):
context
.
REQUEST
.
RESPONSE
.
setStatus
(
401
)
if
error
is
not
None
:
return
handleError
(
error
)
elif
code
is
not
None
:
portal
=
context
.
getPortalObject
()
response_dict
=
context
.
ERP5Site_getFacebookAccessTokenFromCode
(
code
,
"{0}/ERP5Site_callbackFacebookLogin"
.
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
)
context
.
REQUEST
.
RESPONSE
.
setCookie
(
'__ac_facebook_hash'
,
hash_str
,
path
=
'/'
)
# store timestamp in second since the epoch in UTC is enough
response_dict
[
"response_timestamp"
]
=
time
.
time
()
context
.
Base_setBearerToken
(
hash_str
,
response_dict
,
"facebook_server_auth_token_cache_factory"
)
user_dict
=
context
.
ERP5Site_getFacebookUserEntry
(
access_token
)
user_reference
=
user_dict
[
"reference"
]
context
.
Base_setBearerToken
(
access_token
,
{
"reference"
:
user_reference
},
"facebook_server_auth_token_cache_factory"
)
method
=
getattr
(
context
,
"ERP5Site_createFacebookUserToOAuth"
,
None
)
if
method
is
not
None
:
method
(
user_reference
,
user_dict
)
person_relative_url
=
context
.
ERP5Site_getPersonFromFacebookLogin
(
user_reference
)
came_from
=
portal
.
absolute_url
()
+
"/#!login?n.me=%s"
%
(
person_relative_url
)
context
.
REQUEST
.
RESPONSE
.
setHeader
(
'Location'
,
came_from
)
context
.
REQUEST
.
RESPONSE
.
setStatus
(
303
)
else
:
return
handleError
(
''
)
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_callbackFacebookLogin.xml
0 → 100644
View file @
e04ac901
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Auditor
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_callbackFacebookLogin
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_receiveGoogleCallback.py
0 → 100644
View file @
e04ac901
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
)
context
.
REQUEST
.
RESPONSE
.
setCookie
(
'__ac_google_hash'
,
hash_str
,
path
=
'/'
)
# 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
)
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
context
.
REQUEST
.
get
(
"came_from"
)
or
context
.
absolute_url
())
return
handleError
(
''
)
master/bt5/slapos_jio/SkinTemplateItem/portal_skins/slapos_hal_json_style/ERP5Site_receiveGoogleCallback.xml
0 → 100644
View file @
e04ac901
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment