mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 05:41:27 +01:00
[BUG] admin authentication source JS errors (#4059)
While trying to understand #1236, I was quite confused not to see the `Use Custom URLs` checkbox. This checkbox disappeared inb95a893b22
(because `getElementById` does not expect a `#` as first char), fixed in4e816e1326
. After solving this, switching from `Nextcloud` to `OpenID Connect` triggered a JS error, which is addressed in3efa4d836a
. Manual testing: - go to http://localhost:3000/admin/auths - click on `Add authentication source` - Choose `Authentication type`: `OAuth2` - Choose `OAuth2 provider`: `Nextcloud` - check that the `Use Custom URLs Instead of Default URLs` checkbox toggles the fields below - let the checkbox be checked - Switch the `OAuth2 provider` to `OpenID Connect` - ensure that no JS error is shown - Switch the `OAuth2 provider` to `Mastodon` - check that the fields below `Use Custom URLs Instead of Default URLs` have the right defaults (mastodon.social) ![2024-06-07-101638.png](/attachments/5bd6692e-3457-4dd8-b1c1-50e9a95a3100) Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4059 Reviewed-by: twenty-panda <twenty-panda@noreply.codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: oliverpool <git@olivier.pfad.fr> Co-committed-by: oliverpool <git@olivier.pfad.fr>
This commit is contained in:
parent
edab0f3a25
commit
82ae7460bf
2 changed files with 12 additions and 7 deletions
1
release-notes/7.0.4/fix/4059.md
Normal file
1
release-notes/7.0.4/fix/4059.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Wrongfully hidden "Use Custom URLs Instead of Default URLs" checkbox on Authentication Source Administration page.
|
|
@ -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');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue