feat(auth): add username field to user schema and authentication process
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
All checks were successful
Build Docker Image / build (push) Successful in 1m12s
- Updated user schema to include a unique username field. - Modified authentication logic to support sign-in using either email or username. - Enhanced sign-up process to require a username and validate its uniqueness. - Updated login and profile routes to reflect changes in user identification. - Adjusted frontend forms to accommodate username input alongside email.
This commit is contained in:
@@ -9,6 +9,15 @@ export const auth = betterAuth({
|
||||
baseURL: env.ORIGIN,
|
||||
secret: env.BETTER_AUTH_SECRET || 'secret',
|
||||
database: drizzleAdapter(db, { provider: 'sqlite' }),
|
||||
user: {
|
||||
additionalFields: {
|
||||
username: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
unique: true
|
||||
}
|
||||
}
|
||||
},
|
||||
emailAndPassword: { enabled: true },
|
||||
plugins: [sveltekitCookies(getRequestEvent)] // make sure this is the last plugin in the array
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
|
||||
export const user = sqliteTable("user", {
|
||||
id: text("id").primaryKey(),
|
||||
name: text("name").notNull(),
|
||||
username: text("username").notNull().unique(),
|
||||
email: text("email").notNull().unique(),
|
||||
emailVerified: integer("email_verified", { mode: "boolean" })
|
||||
.default(false)
|
||||
|
||||
Reference in New Issue
Block a user