2026-09-28 19:44:37 +02:00
|
|
|
'use strict';
|
|
|
|
|
const form = document.getElementById('login-form');
|
|
|
|
|
const button = document.getElementById('nsg-x1-logon-button');
|
|
|
|
|
const message = document.getElementById('message');
|
2026-10-07 07:32:34 +02:00
|
|
|
async function authenticate(path, body) {
|
|
|
|
|
const response = await fetch(path, {
|
|
|
|
|
method: 'POST', body, credentials: 'same-origin', redirect: 'error',
|
|
|
|
|
headers: { Accept: 'application/vnd.citrix.authenticateresponse-1+xml' },
|
|
|
|
|
signal: AbortSignal.timeout(10000)
|
|
|
|
|
});
|
|
|
|
|
if (!response.ok) throw new Error('Request failed');
|
|
|
|
|
const result = rdx.utils.authentication(await response.text());
|
|
|
|
|
form.elements.StateContext.value = result.state;
|
|
|
|
|
// Only the local authentication endpoint can receive form credentials.
|
|
|
|
|
if (result.postback === '/nf/auth/doAuthentication.do') form.action = result.postback;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
const ready = authenticate('/nf/auth/getAuthenticationRequirements.do', new URLSearchParams())
|
|
|
|
|
.catch(() => null);
|
2026-09-28 19:44:37 +02:00
|
|
|
form.addEventListener('submit', async event => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
button.disabled = true;
|
|
|
|
|
message.textContent = '';
|
|
|
|
|
try {
|
2026-10-07 07:32:34 +02:00
|
|
|
await ready;
|
2026-09-28 19:44:37 +02:00
|
|
|
const body = new URLSearchParams(new FormData(form));
|
|
|
|
|
body.set('nsg-x1-logon-button', 'Log On');
|
2026-10-07 07:32:34 +02:00
|
|
|
const result = await authenticate('/nf/auth/doAuthentication.do', body);
|
|
|
|
|
message.textContent = result.errors.join(' ') || 'Anmeldung fehlgeschlagen. Überprüfen Sie Ihre Zugangsdaten.';
|
2026-09-28 19:44:37 +02:00
|
|
|
} catch {
|
|
|
|
|
message.textContent = 'Die Anmeldung ist derzeit nicht möglich. Versuchen Sie es erneut.';
|
|
|
|
|
} finally {
|
|
|
|
|
form.elements.passwd.value = '';
|
|
|
|
|
button.disabled = false;
|
|
|
|
|
}
|
|
|
|
|
});
|