advance
This commit is contained in:
34
lib/auth/demoAuth.ts
Normal file
34
lib/auth/demoAuth.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
export const DEMO_AUTH_EMAIL_COOKIE = "acve_demo_email";
|
||||
export const DEMO_AUTH_ROLE_COOKIE = "acve_demo_role";
|
||||
|
||||
type DemoAccount = {
|
||||
email: string;
|
||||
password: string;
|
||||
role: "teacher" | "learner";
|
||||
};
|
||||
|
||||
const demoAccounts: DemoAccount[] = [
|
||||
{
|
||||
email: "teacher@acve.local",
|
||||
password: "teacher123",
|
||||
role: "teacher",
|
||||
},
|
||||
{
|
||||
email: "learner@acve.local",
|
||||
password: "learner123",
|
||||
role: "learner",
|
||||
},
|
||||
];
|
||||
|
||||
export const demoCredentialsHint = demoAccounts
|
||||
.map((account) => `${account.email} / ${account.password}`)
|
||||
.join(" | ");
|
||||
|
||||
export const findDemoAccount = (email: string, password: string): DemoAccount | null => {
|
||||
const cleanEmail = email.trim().toLowerCase();
|
||||
return (
|
||||
demoAccounts.find(
|
||||
(account) => account.email.toLowerCase() === cleanEmail && account.password === password,
|
||||
) ?? null
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user