login.html/login.js: the two reset views are gone along with the reset-token handling, and the sign-in form now says which password to type - "your Windows password, the same one you use to sign in to your computer" - using the .hint class the page already had, so no new CSS and no new literal. "Forgot password?" is KEPT and points at https://primecontrols.okta.com/. An earlier draft of this task deleted the link and I proposed a plain "contact IT" sentence instead; Okta is the better answer, and with no app password and no break-glass it is the only recovery path that exists. Three details that would each have broken it: - The old click handler on #forgot-link called preventDefault() to swap views. Left in place it would have silently swallowed the navigation, so the link would look right and do nothing. There is now deliberately no handler, and login.js says why so nobody adds one back. - target="_blank" without rel="noopener noreferrer" hands the opened page a window.opener handle back to the login page. - Worth recording since it was checked rather than assumed: the CSP allows this. form-action 'self' governs form submission, not link navigation, and no navigate-to directive is set - so a plain <a href> off-origin is fine and the nginx config needs no change. login.js also handles 503 distinctly now. T10.2 made that mean "the directory is unreachable or misconfigured", which is our fault - showing "invalid password" would send people hunting for a password they no longer have while a deploy is broken. Also removed, because T10.3 deleted the endpoints behind them and leaving them would have produced visible 404s rather than dead-but-harmless markup: auth-guard.js the whole change-password dialog (POST /api/auth/password) wp-sidenav.js the "Password / Change your password" menu entry that opened it users.js the per-row "Reset password" action users.js the password field in the create-account form - NewUserIn no users.html longer accepts one, so the form was posting a rejected field The self-row placeholder button pointed at a top-bar Password link that no longer exists; it is now a plain "you" marker. Verified: node --check passes on all four touched JS files; the only password references left in html/ are the sign-in form and the SMTP config in admin.js, which is unrelated and stays. Logged BL-027 rather than acted on: the Okta URL is the first sign of an Okta tenant on this estate, which means an OIDC flow is available in principle and would remove the domain-lockout hazard that forced AUTH_MAX_ATTEMPTS to 2. D13 was decided and reaffirmed and T10.1-T10.4 are built, so swapping the mechanism mid-wave is the reordering CLAUDE.md forbids. Recording is not reopening. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
95 lines
3.9 KiB
JavaScript
95 lines
3.9 KiB
JavaScript
/* Login page logic for the Work Package Suite.
|
|
|
|
One view. Sign in posts to /api/auth/login, the server authenticates by binding
|
|
to the domain over LDAPS (D13), and on success sets an HttpOnly session cookie —
|
|
not readable from here, which is the point — after which we redirect to ?next=
|
|
or the home page. The password entered is the person's WINDOWS password.
|
|
|
|
There is no forgot-password flow and no reset view: the suite holds no password
|
|
to reset. "Forgot password?" is a plain external link to Okta in login.html, so
|
|
there is deliberately no click handler for it here — one that called
|
|
preventDefault() would swallow the navigation. */
|
|
(function () {
|
|
'use strict';
|
|
|
|
var errorBox = document.getElementById('error');
|
|
var okBox = document.getElementById('ok');
|
|
|
|
function byId(id) { return document.getElementById(id); }
|
|
|
|
function showError(msg) {
|
|
okBox.classList.remove('show');
|
|
errorBox.textContent = msg;
|
|
errorBox.classList.add('show');
|
|
}
|
|
function clearBanners() {
|
|
errorBox.classList.remove('show');
|
|
okBox.classList.remove('show');
|
|
}
|
|
|
|
// Where to go after signing in: the ?next= param if it's a safe same-site
|
|
// path, otherwise the home page. (Reject absolute/scheme URLs to avoid an
|
|
// open-redirect.)
|
|
function nextTarget() {
|
|
try {
|
|
var next = new URLSearchParams(location.search).get('next') || '';
|
|
if (next && next.charAt(0) === '/' && next.charAt(1) !== '/') return next;
|
|
} catch (e) {}
|
|
return 'index.html';
|
|
}
|
|
|
|
function postJson(url, payload) {
|
|
return fetch(url, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload)
|
|
}).then(function (r) {
|
|
return r.json().catch(function () { return null; }).then(function (j) {
|
|
return { status: r.status, ok: r.ok, json: j };
|
|
});
|
|
});
|
|
}
|
|
|
|
function detail(res, fallback) {
|
|
var d = res && res.json && res.json.detail;
|
|
return (typeof d === 'string' && d) ? d : fallback;
|
|
}
|
|
|
|
// ── sign in ────────────────────────────────────────────────────────────────
|
|
var form = byId('login-form');
|
|
var submitBtn = byId('submit');
|
|
// Guarded: an unguarded addEventListener on null would break sign-in itself if a
|
|
// cached older login.html were served.
|
|
if (!form || !submitBtn) return;
|
|
form.addEventListener('submit', function (e) {
|
|
e.preventDefault();
|
|
clearBanners();
|
|
var username = byId('username').value.trim();
|
|
var password = byId('password').value;
|
|
if (!username || !password) { showError('Enter your username and password.'); return; }
|
|
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Signing in…';
|
|
postJson('/api/auth/login', { username: username, password: password })
|
|
.then(function (res) {
|
|
if (res.ok) { location.replace(nextTarget()); return; }
|
|
if (res.status === 401) showError('Invalid username or password.');
|
|
else if (res.status === 403) showError(detail(res, 'Your account is disabled.'));
|
|
else if (res.status === 429) showError(detail(res, 'Too many failed attempts. Try again later.'));
|
|
// 503 means the directory is unreachable or misconfigured — OUR fault, not a
|
|
// wrong password. Saying so stops people hunting for a password they no
|
|
// longer have while a deploy is broken.
|
|
else if (res.status === 503) showError(detail(res, 'Sign-in is temporarily unavailable. Contact IT.'));
|
|
else showError(detail(res, 'Sign-in failed (HTTP ' + res.status + ').'));
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Sign in';
|
|
})
|
|
.catch(function () {
|
|
showError('Could not reach the server. Check your connection and try again.');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Sign in';
|
|
});
|
|
});
|
|
|
|
})();
|