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 servicerelease/v1.15
parent
ad1164f73b
commit
24ecdbdb0d
|
@ -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, .oauth2_use_custom_url').hide();
|
||||||
$('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');
|
$('.open_id_connect_auto_discovery_url input[required]').removeAttr('required');
|
||||||
|
|
||||||
const provider = $('#oauth2_provider').val();
|
const provider = $('#oauth2_provider').val();
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
case 'github':
|
|
||||||
case 'gitlab':
|
|
||||||
case 'gitea':
|
case 'gitea':
|
||||||
case 'nextcloud':
|
case 'nextcloud':
|
||||||
case 'mastodon':
|
case 'mastodon':
|
||||||
|
$('#oauth2_use_custom_url').attr('checked', 'checked');
|
||||||
|
// fallthrough intentional
|
||||||
|
case 'github':
|
||||||
|
case 'gitlab':
|
||||||
$('.oauth2_use_custom_url').show();
|
$('.oauth2_use_custom_url').show();
|
||||||
break;
|
break;
|
||||||
case 'openidConnect':
|
case 'openidConnect':
|
||||||
|
@ -1850,19 +1852,21 @@ function initAdmin() {
|
||||||
$('.open_id_connect_auto_discovery_url').show();
|
$('.open_id_connect_auto_discovery_url').show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
onOAuth2UseCustomURLChange();
|
onOAuth2UseCustomURLChange(applyDefaultValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onOAuth2UseCustomURLChange() {
|
function onOAuth2UseCustomURLChange(applyDefaultValues) {
|
||||||
const provider = $('#oauth2_provider').val();
|
const provider = $('#oauth2_provider').val();
|
||||||
$('.oauth2_use_custom_url_field').hide();
|
$('.oauth2_use_custom_url_field').hide();
|
||||||
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');
|
$('.oauth2_use_custom_url_field input[required]').removeAttr('required');
|
||||||
|
|
||||||
if ($('#oauth2_use_custom_url').is(':checked')) {
|
if ($('#oauth2_use_custom_url').is(':checked')) {
|
||||||
|
if (applyDefaultValues) {
|
||||||
$('#oauth2_token_url').val($(`#${provider}_token_url`).val());
|
$('#oauth2_token_url').val($(`#${provider}_token_url`).val());
|
||||||
$('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());
|
$('#oauth2_auth_url').val($(`#${provider}_auth_url`).val());
|
||||||
$('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());
|
$('#oauth2_profile_url').val($(`#${provider}_profile_url`).val());
|
||||||
$('#oauth2_email_url').val($(`#${provider}_email_url`).val());
|
$('#oauth2_email_url').val($(`#${provider}_email_url`).val());
|
||||||
|
}
|
||||||
|
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
case 'github':
|
case 'github':
|
||||||
|
@ -1923,7 +1927,7 @@ function initAdmin() {
|
||||||
case '6': // OAuth2
|
case '6': // OAuth2
|
||||||
$('.oauth2').show();
|
$('.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');
|
$('.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;
|
break;
|
||||||
case '7': // SSPI
|
case '7': // SSPI
|
||||||
$('.sspi').show();
|
$('.sspi').show();
|
||||||
|
@ -1941,8 +1945,8 @@ function initAdmin() {
|
||||||
$('#auth_type').trigger('change');
|
$('#auth_type').trigger('change');
|
||||||
$('#security_protocol').on('change', onSecurityProtocolChange);
|
$('#security_protocol').on('change', onSecurityProtocolChange);
|
||||||
$('#use_paged_search').on('change', onUsePagedSearchChange);
|
$('#use_paged_search').on('change', onUsePagedSearchChange);
|
||||||
$('#oauth2_provider').on('change', onOAuth2Change);
|
$('#oauth2_provider').on('change', () => onOAuth2Change(true));
|
||||||
$('#oauth2_use_custom_url').on('change', onOAuth2UseCustomURLChange);
|
$('#oauth2_use_custom_url').on('change', () => onOAuth2UseCustomURLChange(true));
|
||||||
$('#groups_enabled').on('change', onVerifyGroupMembershipChange);
|
$('#groups_enabled').on('change', onVerifyGroupMembershipChange);
|
||||||
}
|
}
|
||||||
// Edit authentication
|
// Edit authentication
|
||||||
|
@ -1956,9 +1960,9 @@ function initAdmin() {
|
||||||
$('#use_paged_search').on('change', onUsePagedSearchChange);
|
$('#use_paged_search').on('change', onUsePagedSearchChange);
|
||||||
}
|
}
|
||||||
} else if (authType === '6') {
|
} else if (authType === '6') {
|
||||||
$('#oauth2_provider').on('change', onOAuth2Change);
|
$('#oauth2_provider').on('change', () => onOAuth2Change(true));
|
||||||
$('#oauth2_use_custom_url').on('change', onOAuth2UseCustomURLChange);
|
$('#oauth2_use_custom_url').on('change', () => onOAuth2UseCustomURLChange(false));
|
||||||
onOAuth2Change();
|
onOAuth2Change(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue