feat(auth) : add admin account management
CI / Verify (push) Successful in 57s
CI / Build immutable images and deploy (push) Successful in 2m7s

This commit is contained in:
2026-09-04 10:54:08 +07:00 Unverified
parent 53b79cc7e8
commit a865913a08
15 changed files with 3703 additions and 245 deletions
+7 -2
View File
@@ -34,8 +34,8 @@ const timestamps = {
.notNull(),
};
// Better Auth core tables. Credential registration is restricted to
// ADMIN_EMAIL, which is rechecked at every protected application boundary.
// Better Auth core tables. Public registration is disabled; authenticated
// administrators create additional credential accounts from the admin area.
export const users = authSchema.table(
"user",
{
@@ -44,6 +44,10 @@ export const users = authSchema.table(
email: text("email").notNull(),
emailVerified: boolean("email_verified").default(false).notNull(),
image: text("image"),
role: text("role").default("admin"),
banned: boolean("banned").default(false),
banReason: text("ban_reason"),
banExpires: timestamp("ban_expires", { withTimezone: true }),
...timestamps,
},
(table) => [uniqueIndex("user_email_unique").on(table.email)],
@@ -60,6 +64,7 @@ export const sessions = authSchema.table(
userId: text("user_id")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
impersonatedBy: text("impersonated_by"),
...timestamps,
},
(table) => [