From 8afc31b4a7b13de18f1c3163949f12127c4ebbad Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 15 Jun 2023 01:57:10 +0800 Subject: [PATCH] show real callback URL for auth source --- options/locale/locale_en-US.ini | 2 +- templates/admin/auth/edit.tmpl | 8 ++++---- templates/admin/auth/new.tmpl | 8 ++++---- web_src/js/features/admin/common.js | 6 ++++++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index db5a45f6127c..65dda101f5b5 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2901,7 +2901,7 @@ auths.sspi_default_language = Default user language auths.sspi_default_language_helper = Default language for users automatically created by SSPI auth method. Leave empty if you prefer language to be automatically detected. auths.tips = Tips auths.tips.oauth2.general = OAuth2 Authentication -auths.tips.oauth2.general.tip = When registering a new OAuth2 authentication, the callback/redirect URL should be: /user/oauth2//callback +auths.tips.oauth2.general.tip = When registering a new OAuth2 authentication, the callback/redirect URL should be: auths.tip.oauth2_provider = OAuth2 Provider auths.tip.bitbucket = Register a new OAuth consumer on https://bitbucket.org/account/user//oauth-consumers/new and add the permission 'Account' - 'Read' auths.tip.nextcloud = Register a new OAuth consumer on your instance using the following menu "Settings -> Security -> OAuth 2.0 client" diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 7f7da3ea9859..c30ee5c5861d 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -14,8 +14,8 @@ {{.Source.TypeName}}
- - + +
@@ -442,8 +442,8 @@
GMail Settings:

Host: smtp.gmail.com, Port: 587, Enable TLS Encryption: true

-
{{.locale.Tr "admin.auths.tips.oauth2.general"}}:
-

{{.locale.Tr "admin.auths.tips.oauth2.general.tip"}}

+
{{.locale.Tr "admin.auths.tips.oauth2.general"}}:
+

{{.locale.Tr "admin.auths.tips.oauth2.general.tip"}}

diff --git a/templates/admin/auth/new.tmpl b/templates/admin/auth/new.tmpl index 5d9a9083c5c8..37d1635c11df 100644 --- a/templates/admin/auth/new.tmpl +++ b/templates/admin/auth/new.tmpl @@ -22,8 +22,8 @@
- - + +
@@ -85,8 +85,8 @@
GMail Settings:

Host: smtp.gmail.com, Port: 587, Enable TLS Encryption: true

-
{{.locale.Tr "admin.auths.tips.oauth2.general"}}:
-

{{.locale.Tr "admin.auths.tips.oauth2.general.tip"}}

+
{{.locale.Tr "admin.auths.tips.oauth2.general"}}:
+

{{.locale.Tr "admin.auths.tips.oauth2.general.tip"}}

{{.locale.Tr "admin.auths.tip.oauth2_provider"}}
diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js index 84fd35e08104..b6b192a29629 100644 --- a/web_src/js/features/admin/common.js +++ b/web_src/js/features/admin/common.js @@ -171,6 +171,12 @@ export function initAdminCommon() { } } + if ($('.admin.authentication').length > 0) { + $('#auth_name').on('input', function () { + $('#oauth2-callback-url').text(`${window.location.origin}/user/oauth2/${encodeURIComponent($(this).val())}/callback`); + }).trigger('input'); + } + // Notice if ($('.admin.notice')) { const $detailModal = $('#detail-modal');