aboutsummaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorNorwin <noerw@users.noreply.github.com>2020-12-26 18:22:42 +0000
committerGitHub <noreply@github.com>2020-12-26 18:22:42 +0000
commit24ecdbdb0d254879d1e060bbaec01c0f7ad9cde9 (patch)
tree47af3ac119548a70247f784409c36637b94fd0d4 /web_src
parentad1164f73ba277f11a20ea838a62d9b8c8a7cb45 (diff)
downloadgitea-24ecdbdb0d254879d1e060bbaec01c0f7ad9cde9.tar.gz
gitea-24ecdbdb0d254879d1e060bbaec01c0f7ad9cde9.zip
Fix UI on edit auth source page (#14137)
* do not override OAuth URLs with default values when editing an auth source (fixes #12014) * show custom url inputs by default for providers that don't provide an official hosted service
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/index.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index dd7032eb84..471adfa425 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -1832,17 +1832,19 @@ function initAdmin() {
}
}
- function onOAuth2Change() {
+ function onOAuth2Change(applyDefaultValues) {
$('.open_id_connect_auto_discovery_url, .oauth2_use_custom_url').hide();
$('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');
const provider = $('#oauth2_provider').val();
switch (provider) {
- case 'github':
- case 'gitlab':
case 'gitea':
case 'nextcloud':
case 'mastodon':
+ $('#oauth2_use_custom_url').attr('checked', 'checked');
+ // fallthrough intentional
+ case 'github':
+ case 'gitlab':
$('.oauth2_use_custom_url').show();
break;
case 'openidConnect':
@@ -1850,19 +1852,21 @@ function initAdmin() {
$('.open_id_connect_auto_discovery_url').show();
break;
}
- onOAuth2UseCustomURLChange();
+ onOAuth2UseCustomURLChange(applyDefaultValues);
}
- function onOAuth2UseCustomURLChange() {
+ function onOAuth2UseCustomURLChange(applyDefaultValues) {
const provider = $('#oauth2_provider').val();
$('.oauth2_use_custom_url_field').hide();
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');
if ($('#oauth2_use_custom_url').is(':checked')) {
- $('#oauth2_token_url').val($(`#${provider}_token_url`).val());
- $('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());
- $('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());
- $('#oauth2_email_url').val($(`#${provider}_email_url`).val());
+ if (applyDefaultValues) {
+ $('#oauth2_token_url').val($(`#${provider}_token_url`).val());
+ $('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());
+ $('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());
+ $('#oauth2_email_url').val($(`#${provider}_email_url`).val());
+ }
switch (provider) {
case 'github':
@@ -1923,7 +1927,7 @@ function initAdmin() {
case '6': // OAuth2
$('.oauth2').show();
$('.oauth2 div.required:not(.oauth2_use_custom_url,.oauth2_use_custom_url_field,.open_id_connect_auto_discovery_url) input').attr('required', 'required');
- onOAuth2Change();
+ onOAuth2Change(true);
break;
case '7': // SSPI
$('.sspi').show();
@@ -1941,8 +1945,8 @@ function initAdmin() {
$('#auth_type').trigger('change');
$('#security_protocol').on('change', onSecurityProtocolChange);
$('#use_paged_search').on('change', onUsePagedSearchChange);
- $('#oauth2_provider').on('change', onOAuth2Change);
- $('#oauth2_use_custom_url').on('change', onOAuth2UseCustomURLChange);
+ $('#oauth2_provider').on('change', () => onOAuth2Change(true));
+ $('#oauth2_use_custom_url').on('change', () => onOAuth2UseCustomURLChange(true));
$('#groups_enabled').on('change', onVerifyGroupMembershipChange);
}
// Edit authentication
@@ -1956,9 +1960,9 @@ function initAdmin() {
$('#use_paged_search').on('change', onUsePagedSearchChange);
}
} else if (authType === '6') {
- $('#oauth2_provider').on('change', onOAuth2Change);
- $('#oauth2_use_custom_url').on('change', onOAuth2UseCustomURLChange);
- onOAuth2Change();
+ $('#oauth2_provider').on('change', () => onOAuth2Change(true));
+ $('#oauth2_use_custom_url').on('change', () => onOAuth2UseCustomURLChange(false));
+ onOAuth2Change(false);
}
}