import { valid, page } from './_auth.js';
function login(error = false) {
return page(`
Advanz | Employee AI Assistant
Employee AI Assistant
Enter your password to continue.
${error ? 'Incorrect password. Please try again.
' : ''}
AUTHORIZED EMPLOYEES ONLY
`);
}
function chat() {
return page(`
Advanz Employee AI
Welcome to your employee AI assistant. Do not enter sensitive member information.
`);
}
export async function onRequestGet({ request, env }) {
if (!env.EMPLOYEE_PASSWORD || !env.SESSION_SECRET) {
return page('Site authentication is not configured.', 503);
}
const authenticated = await valid(request, env);
if (authenticated) return chat();
return login(new URL(request.url).searchParams.has('error'));
}