ba8bfc3f46
User-facing - New post-login home (/home): chat rail + Share/Connect (embedded) + Meeting; login lives here when logged out - Landing: "Log in with BizGaze" + no-login screen share - Console replaced by a role-scoped Dashboard (/dashboard): admins see all team sessions, others see only their own; stats + CSV/PDF export - Recordings saved as MP4 (H.264/AAC) with WebM fallback; old .webm still downloadable - Fix: duplicate "Sign in" on the login card Auth / integration - BizGaze as identity provider: /api/login validates against BIZGAZE_LOGIN_URL (env-gated) and provisions a local user - Phase 2 start: /api/v1 alias for all /api routes; Authorization: Bearer accepted across HTTP + WS; login returns a token (for native desktop/mobile clients) Backend refactor (Phase 1, behavior-preserving) - Split server.js into config/lib/session/presence/routes/static/signaling + repos (data-access) + bizgaze (service) - All SQL behind repos.js, tenant-scoped (tenantId == team_id for now) - e2e updated to current flow (21/21 pass before and after) Docs: ARCHITECTURE.md (target architecture + phased plan), CLAUDE.md repo layout, .env.example BIZGAZE_LOGIN_URL Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 righe
1.7 KiB
JavaScript
44 righe
1.7 KiB
JavaScript
// BizGaze as identity provider.
|
|
// Validates a username/password against BizGaze's ValidateAndLogin endpoint.
|
|
// Enabled only when BIZGAZE_LOGIN_URL is set (so tests/local runs stay self-contained).
|
|
//
|
|
// Success response shape (observed):
|
|
// { status: 1, currentSession: { name, userId, tenantId, unibaseId, isAdmin, ... }, message }
|
|
// Failure: status !== 1, with a `message`.
|
|
|
|
function loginUrl() { return process.env.BIZGAZE_LOGIN_URL || ''; }
|
|
const isEnabled = () => !!loginUrl();
|
|
|
|
async function validateLogin(username, password) {
|
|
const url = loginUrl();
|
|
if (!url) return { ok: false, configured: false };
|
|
let res;
|
|
try {
|
|
res = await fetch(url, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ UserName: username, Password: password, UnibaseId: '', RememberMe: false }),
|
|
signal: AbortSignal.timeout(15000),
|
|
});
|
|
} catch (e) {
|
|
return { ok: false, configured: true, error: 'BizGaze sign-in is unavailable right now' };
|
|
}
|
|
let data;
|
|
try { data = await res.json(); } catch { return { ok: false, configured: true, error: 'Unexpected response from BizGaze' }; }
|
|
const s = data && data.currentSession;
|
|
if (data && data.status === 1 && s) {
|
|
return {
|
|
ok: true, configured: true,
|
|
name: s.name || null,
|
|
isAdmin: !!s.isAdmin,
|
|
tenantRef: s.tenantId != null ? String(s.tenantId) : null, // BizGaze tenant (org) id
|
|
bizgazeUserId: s.userId != null ? String(s.userId) : null,
|
|
unibaseId: s.unibaseId || null,
|
|
message: data.message || 'Login Success',
|
|
};
|
|
}
|
|
return { ok: false, configured: true, message: (data && data.message) || 'Invalid BizGaze credentials' };
|
|
}
|
|
|
|
module.exports = { validateLogin, isEnabled };
|