Merge pull request '[v7.0/forgejo] [BUG] admin authentication source JS errors' (#4159) from bp-v7.0/forgejo-82ae746 into v7.0/forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4159
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-06-17 10:39:29 +00:00
commit 2d42dbc495
2 changed files with 12 additions and 7 deletions

View file

@ -0,0 +1 @@
Wrongfully hidden "Use Custom URLs Instead of Default URLs" checkbox on Authentication Source Administration page.

View file

@ -75,14 +75,17 @@ export function initAdminCommon() {
} }
showElem('.open_id_connect_auto_discovery_url'); showElem('.open_id_connect_auto_discovery_url');
break; break;
default: default: {
if (document.getElementById(`#${provider}_customURLSettings`)?.getAttribute('data-required')) { const customURLSettings = document.getElementById(`${provider}_customURLSettings`);
if (!customURLSettings) break;
if (customURLSettings.getAttribute('data-required')) {
document.getElementById('oauth2_use_custom_url')?.setAttribute('checked', 'checked'); document.getElementById('oauth2_use_custom_url')?.setAttribute('checked', 'checked');
} }
if (document.getElementById(`#${provider}_customURLSettings`)?.getAttribute('data-available')) { if (customURLSettings.getAttribute('data-available')) {
showElem('.oauth2_use_custom_url'); showElem('.oauth2_use_custom_url');
} }
} }
}
onOAuth2UseCustomURLChange(applyDefaultValues); onOAuth2UseCustomURLChange(applyDefaultValues);
} }
@ -95,11 +98,12 @@ export function initAdminCommon() {
if (document.getElementById('oauth2_use_custom_url')?.checked) { if (document.getElementById('oauth2_use_custom_url')?.checked) {
for (const custom of ['token_url', 'auth_url', 'profile_url', 'email_url', 'tenant']) { for (const custom of ['token_url', 'auth_url', 'profile_url', 'email_url', 'tenant']) {
if (applyDefaultValues) {
document.getElementById(`oauth2_${custom}`).value = document.getElementById(`${provider}_${custom}`).value;
}
const customInput = document.getElementById(`${provider}_${custom}`); const customInput = document.getElementById(`${provider}_${custom}`);
if (customInput && customInput.getAttribute('data-available')) { if (!customInput) continue;
if (applyDefaultValues) {
document.getElementById(`oauth2_${custom}`).value = customInput.value;
}
if (customInput.getAttribute('data-available')) {
for (const input of document.querySelectorAll(`.oauth2_${custom} input`)) { for (const input of document.querySelectorAll(`.oauth2_${custom} input`)) {
input.setAttribute('required', 'required'); input.setAttribute('required', 'required');
} }