-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2091 from cogk/feat-pwa-login-via-oauth
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import frappe | ||
|
||
|
||
@frappe.whitelist(allow_guest=True) | ||
def oauth_providers(): | ||
from frappe.utils.html_utils import get_icon_html | ||
from frappe.utils.oauth import get_oauth2_authorize_url, get_oauth_keys | ||
from frappe.utils.password import get_decrypted_password | ||
|
||
out = [] | ||
providers = frappe.get_all( | ||
"Social Login Key", | ||
filters={"enable_social_login": 1}, | ||
fields=["name", "client_id", "base_url", "provider_name", "icon"], | ||
order_by="name", | ||
) | ||
|
||
for provider in providers: | ||
client_secret = get_decrypted_password("Social Login Key", provider.name, "client_secret") | ||
if not client_secret: | ||
continue | ||
|
||
if provider.client_id and provider.base_url and get_oauth_keys(provider.name): | ||
out.append( | ||
{ | ||
"name": provider.name, | ||
"provider_name": provider.provider_name, | ||
"auth_url": get_oauth2_authorize_url(provider.name, "/hrms"), | ||
"icon": provider.icon, | ||
} | ||
) | ||
|
||
return out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters