Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
amrani
erp5
Commits
a3e448f1
Commit
a3e448f1
authored
Sep 26, 2017
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Security: Define getFacebookUserEntry to reduce code duplication
This method and call is duplicated on several places
parent
b0923a89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
27 deletions
+29
-27
product/ERP5Security/ERP5ExternalOauth2ExtractionPlugin.py
product/ERP5Security/ERP5ExternalOauth2ExtractionPlugin.py
+29
-27
No files found.
product/ERP5Security/ERP5ExternalOauth2ExtractionPlugin.py
View file @
a3e448f1
...
...
@@ -226,19 +226,7 @@ class ERP5ExternalOauth2ExtractionPlugin:
creds
[
'remote_address'
]
=
request
.
get
(
'REMOTE_ADDR'
,
''
)
return
creds
class
ERP5FacebookExtractionPlugin
(
ERP5ExternalOauth2ExtractionPlugin
,
BasePlugin
):
"""
Plugin to authenicate as machines.
"""
meta_type
=
"ERP5 Facebook Extraction Plugin"
cookie_name
=
"__ac_facebook_hash"
cache_factory_name
=
"facebook_server_auth_token_cache_factory"
def
refreshTokenIfExpired
(
self
,
key
,
cache_value
):
return
cache_value
def
getUserEntry
(
self
,
token
):
def
getFacebookUserEntry
(
token
):
if
facebook
is
None
:
LOG
(
'ERP5FacebookExtractionPlugin'
,
INFO
,
'No facebook module, install facebook-sdk package. '
...
...
@@ -249,24 +237,38 @@ class ERP5FacebookExtractionPlugin(ERP5ExternalOauth2ExtractionPlugin, BasePlugi
# require really fast interaction
socket
.
setdefaulttimeout
(
5
)
facebook_entry
=
facebook
.
GraphAPI
(
token
).
get_object
(
"me"
)
except
Exception
:
facebook_entry
=
None
finally
:
socket
.
setdefaulttimeout
(
timeout
)
user_entry
=
{}
if
facebook_entry
is
not
None
:
# sanitise value
for
k
in
(
'name'
,
'id'
):
try
:
for
k
in
(
'first_name'
,
'last_name'
,
'id'
,
'email'
):
if
k
==
'id'
:
user_entry
[
'reference'
]
=
facebook_entry
[
k
].
encode
(
'utf-8'
)
else
:
user_entry
[
k
]
=
facebook_entry
[
k
].
encode
(
'utf-8'
)
except
KeyError
:
user_entry
=
None
raise
ValueError
(
facebook_entry
)
return
user_entry
class
ERP5FacebookExtractionPlugin
(
ERP5ExternalOauth2ExtractionPlugin
,
BasePlugin
):
"""
Plugin to authenicate as machines.
"""
meta_type
=
"ERP5 Facebook Extraction Plugin"
login_portal_type
=
"Facebook Login"
cookie_name
=
"__ac_facebook_hash"
cache_factory_name
=
"facebook_server_auth_token_cache_factory"
def
refreshTokenIfExpired
(
self
,
key
,
cache_value
):
return
cache_value
def
getUserEntry
(
self
,
token
):
return
getFacebookUserDict
(
token
)
class
ERP5GoogleExtractionPlugin
(
ERP5ExternalOauth2ExtractionPlugin
,
BasePlugin
):
"""
Plugin to authenicate as machines.
...
...
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