generate 2fa backup codes

This commit is contained in:
Milo Schwartz 2024-10-05 15:31:28 -04:00
parent dca6924a5c
commit 3df14fb8f5
4 changed files with 40 additions and 5 deletions

View file

@ -83,6 +83,14 @@ export const users = sqliteTable("user", {
.default(false),
});
export const twoFactorBackupCodes = sqliteTable("twoFactorBackupCodes", {
id: integer("id").primaryKey({ autoIncrement: true }),
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
codeHash: text("codeHash").notNull(),
});
// Sessions table
export const sessions = sqliteTable("session", {
id: text("id").primaryKey(), // has to be id not sessionId for lucia
@ -124,3 +132,4 @@ export type Session = InferSelectModel<typeof sessions>;
export type EmailVerificationCode = InferSelectModel<
typeof emailVerificationCodes
>;
export type TwoFactorBackupCode = InferSelectModel<typeof twoFactorBackupCodes>;