docs: Phase 2 accounts & roles — roadmap, README, session log
This commit is contained in:
@@ -35,10 +35,16 @@ const REFERENCE_ACTIVITIES: { name: string; insoleTypes: string[] }[] = [
|
||||
|
||||
async function seedDevUsers(): Promise<void> {
|
||||
if (process.env.NODE_ENV === 'production') return;
|
||||
// better-auth's admin plugin types `role` as its built-in set ('user' | 'admin'); our custom
|
||||
// 'worker' role is valid at runtime but not in that static type, so narrow createUser locally
|
||||
// (same workaround as test/helpers.ts).
|
||||
const createUser = auth.api.createUser as (args: {
|
||||
body: { email: string; password: string; name: string; role: 'worker' | 'admin' };
|
||||
}) => Promise<unknown>;
|
||||
for (const acc of DEV_ACCOUNTS) {
|
||||
const existing = await db.select().from(user).where(eq(user.email, acc.email));
|
||||
if (existing.length > 0) continue;
|
||||
await auth.api.createUser({
|
||||
await createUser({
|
||||
body: { email: acc.email, password: acc.password, name: acc.name, role: acc.role },
|
||||
});
|
||||
console.log(`Seeded dev ${acc.role}: ${acc.email} / ${acc.password}`);
|
||||
|
||||
Reference in New Issue
Block a user