fix: complete two_factor schema to full plugin field set
Adds failedVerificationCount and lockedUntil (brute-force tracking maintained by the two-factor plugin). The adapter rejects any two-factor endpoint while declared fields are missing from the drizzle schema; verified was already added in the previous commit.
This commit is contained in:
1 parent
f42f4d5d2d
commit
11cde23cdb
4 files changed
+1971
-4
No files matched your search
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE "two_factor" ADD COLUMN "failed_verification_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "two_factor" ADD COLUMN "locked_until" timestamp with time zone;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -85,6 +85,13 @@
|
||||
"when": 1787620365940,
|
||||
"tag": "0011_two-factor-verified",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "7",
|
||||
"when": 1787621254728,
|
||||
"tag": "0012_two-factor-plugin-fields",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { boolean, pgEnum, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { boolean, integer, pgEnum, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
|
||||
export const portalRoles = ["ADMIN", "EDITORIAL"] as const;
|
||||
export const portalRole = pgEnum("portal_role", portalRoles);
|
||||
@@ -16,9 +16,10 @@ export const users = pgTable("user", {
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
// Better Auth two-factor plugin model ("twoFactor"). `secret` and
|
||||
// `backupCodes` are stored encrypted by Better Auth (derived from
|
||||
// BETTER_AUTH_SECRET).
|
||||
// Better Auth two-factor plugin model ("twoFactor"). Field set mirrors the
|
||||
// plugin's schema declaration (secret, backupCodes, userId, verified,
|
||||
// failedVerificationCount, lockedUntil); `secret` and `backupCodes` are
|
||||
// stored encrypted by Better Auth (derived from BETTER_AUTH_SECRET).
|
||||
export const twoFactors = pgTable("two_factor", {
|
||||
id: uuid("id").defaultRandom().primaryKey(),
|
||||
userId: uuid("user_id")
|
||||
@@ -30,6 +31,9 @@ export const twoFactors = pgTable("two_factor", {
|
||||
// Set by Better Auth's verify-totp step; enable returns verified=false until
|
||||
// the first valid TOTP code confirms possession of the authenticator.
|
||||
verified: boolean("verified").notNull().default(false),
|
||||
// Brute-force protection per row, maintained by the plugin.
|
||||
failedVerificationCount: integer("failed_verification_count").notNull().default(0),
|
||||
lockedUntil: timestamp("locked_until", { withTimezone: true }),
|
||||
});
|
||||
|
||||
export const accounts = pgTable("account", {
|
||||
|
||||
Reference in new issue
Block a user