export const STARTER_PASSWORD = "mega2026"; export const SESSION_COOKIE = "mega_session"; const validEmail = (email: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) && email.length <= 254; export function validateLogin(email: string, password: string): string | null { if (!validEmail(email.trim()) || !password) return "Enter your email and password."; return null; } export function validateNewPassword(password: string, confirmation: string): string | null { if (password.length < 8) return "Choose a password with at least 8 characters."; if (password === STARTER_PASSWORD) return "Choose a password different from the starter password."; if (password !== confirmation) return "The passwords do not match."; return null; } export function validateNewUser(name: string, email: string): string | null { if (!name.trim()) return "Enter the person's name."; if (!validEmail(email.trim())) return "Enter a valid email address."; return null; } export function authDestination(session: { passwordChanged: boolean } | null): string { return !session ? "/login" : session.passwordChanged ? "/" : "/change-password"; }