Commit 2f395e96 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_oauth_[google/facebook]_login: Drop minor duplication

See merge request nexedi/erp5!1607
parents b787ad1c 72a74a6f
Pipeline #21184 failed with stage
in 0 seconds
......@@ -9,12 +9,7 @@ def _getFacebookClientIdAndSecretKey(portal, reference="default"):
Internal function.
"""
result_list = portal.portal_catalog.unrestrictedSearchResults(
portal_type="Facebook Connector",
reference=reference,
validation_state="validated",
limit=2,
)
result_list = unrestrictedSearchFacebookConnector(portal, reference=reference)
assert result_list, "Facebook Connector not found"
if len(result_list) == 2:
raise ValueError("Impossible to select one Facebook Connector")
......@@ -38,10 +33,10 @@ def getAccessTokenFromCode(self, code, redirect_uri):
code=code, redirect_uri=redirect_uri,
app_id=client_id, app_secret=secret_key)
def unrestrictedSearchFacebookConnector(self):
def unrestrictedSearchFacebookConnector(self, reference="default"):
return self.getPortalObject().portal_catalog.unrestrictedSearchResults(
portal_type="Facebook Connector",
reference="default",
reference=reference,
validation_state="validated",
limit=2)
......
......@@ -13,12 +13,7 @@ def _getGoogleClientIdAndSecretKey(portal, reference="default"):
Internal function.
"""
result_list = portal.portal_catalog.unrestrictedSearchResults(
portal_type="Google Connector",
reference=reference,
validation_state="validated",
limit=2,
)
result_list = unrestrictedSearchGoogleConnector(portal, reference=reference)
assert result_list, "Google Connector not found"
if len(result_list) == 2:
raise ValueError("Impossible to select one Google Connector")
......@@ -51,10 +46,10 @@ def getAccessTokenFromCode(self, code, redirect_uri):
credential_data = json.loads(credential.to_json())
return credential_data
def unrestrictedSearchGoogleConnector(self):
def unrestrictedSearchGoogleConnector(self, reference="default"):
return self.getPortalObject().portal_catalog.unrestrictedSearchResults(
portal_type="Google Connector",
reference="default",
reference=reference,
validation_state="validated",
limit=2)
......
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