mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-14 02:37:55 +02:00
feat: Introduce NextAuth.js for authentication, including default admin seeding and user table auto-creation.
This commit is contained in:
1 parent
3ce22defa7
commit
47872a994f
2 files changed
+21
-10
No files matched your search
@@ -28,16 +28,19 @@ export async function ensureAdminExists() {
|
||||
.limit(1);
|
||||
|
||||
if (adminUser.length === 0) {
|
||||
console.log("BMAD: Default admin account not found. Initializing (admin/admin)...");
|
||||
console.log("[AUTH] Admin user not found. Seeding default (admin/admin)...");
|
||||
await db.insert(users).values({
|
||||
username: "admin",
|
||||
passwordHash: hashPassword("admin"),
|
||||
role: "admin"
|
||||
});
|
||||
console.log("[AUTH] Default admin seeded successfully.");
|
||||
return true;
|
||||
} else {
|
||||
console.log("[AUTH] Admin user already exists.");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("BMAD: CRITICAL Error checking/seeding users table.", err);
|
||||
} catch (err: any) {
|
||||
console.error("[AUTH] CRITICAL Error during ensureAdminExists:", err.message || err);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in new issue
Block a user