fix(auth): add account, session, and verification schemas; make passwordHash nullable
This commit is contained in:
@@ -16,6 +16,9 @@ export const auth = betterAuth({
|
|||||||
schema: {
|
schema: {
|
||||||
...schema,
|
...schema,
|
||||||
user: schema.users,
|
user: schema.users,
|
||||||
|
account: schema.accounts,
|
||||||
|
session: schema.sessions,
|
||||||
|
verification: schema.verifications,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
advanced: {
|
advanced: {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export const users = pgTable('users', {
|
|||||||
id: uuid('id').defaultRandom().primaryKey(),
|
id: uuid('id').defaultRandom().primaryKey(),
|
||||||
email: varchar('email', { length: 255 }).notNull().unique(),
|
email: varchar('email', { length: 255 }).notNull().unique(),
|
||||||
name: varchar('name', { length: 255 }).notNull(),
|
name: varchar('name', { length: 255 }).notNull(),
|
||||||
passwordHash: varchar('password_hash', { length: 255 }).notNull(),
|
passwordHash: varchar('password_hash', { length: 255 }),
|
||||||
emailVerified: boolean('email_verified').default(false).notNull(),
|
emailVerified: boolean('email_verified').default(false).notNull(),
|
||||||
image: text('image'),
|
image: text('image'),
|
||||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||||
|
|||||||
1
Backend/drizzle/0013_users_password_hash_nullable.sql
Normal file
1
Backend/drizzle/0013_users_password_hash_nullable.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "users" ALTER COLUMN "password_hash" DROP NOT NULL;
|
||||||
@@ -92,6 +92,13 @@
|
|||||||
"when": 1770740394562,
|
"when": 1770740394562,
|
||||||
"tag": "0012_natural_daredevil",
|
"tag": "0012_natural_daredevil",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 13,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1770800000000,
|
||||||
|
"tag": "0013_users_password_hash_nullable",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,13 @@
|
|||||||
const payload = await response.json().catch(() => ({}));
|
const payload = await response.json().catch(() => ({}));
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(payload.message || response.statusText);
|
const errorMessage =
|
||||||
|
payload?.message ||
|
||||||
|
payload?.error?.message ||
|
||||||
|
payload?.error ||
|
||||||
|
payload?.code ||
|
||||||
|
`${response.status} ${response.statusText}`;
|
||||||
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
|
|||||||
Reference in New Issue
Block a user