DragonCoder99
DragonCoder99
Explore posts from servers
BABetter Auth
Created by DragonCoder99 on 3/25/2025 in #help
Help with Seeding Existing Users into Better Auth
Hi everyone, I’m looking for guidance on integrating my existing users with Better Auth. My users are already formatted in JSON, all using email/password authentication, and their passwords are already encrypted. I’ve already set up Better Auth’s options to work correctly with BCryptJS. My setup: Database: Neon PostgreSQL ORM: Drizzle Framework: Next.js 15 My concerns: User IDs – Better Auth seems to generate its own IDs rather than using the database’s auto-incremented IDs. Accounts Table – Since my users log in via email/password, I believe I need to create an Account record for each user. I’m unsure how to properly seed my existing users so that Better Auth recognizes them. If anyone has experience with this or can point me in the right direction, I’d really appreciate the help! Thanks for your time!
26 replies
BABetter Auth
Created by DragonCoder99 on 2/18/2025 in #help
Using BcryptJS with Better-Auth
Hi everyone, I’m looking for an example of how to use BcryptJS with Better-Auth. I have existing users with bcrypt-hashed passwords, so I need to configure the password option properly for both hashing and verifying passwords. The documentation mentions: "You can customize the password hashing function by setting the password option in the configuration. This option should include a hash function to hash passwords and a verify function to verify them." However, I haven’t found any examples or further details, and this option isn’t listed in the options reference. If anyone can provide an example or point me in the right direction, I’d really appreciate it! Thanks!
7 replies
DTDrizzle Team
Created by DragonCoder99 on 10/18/2024 in #help
Using UUID v7 with Drizzle?
Can I use UUID V7 or some other sortable ID primary column that is not a easy number?
3 replies
DTDrizzle Team
Created by DragonCoder99 on 10/6/2024 in #help
pgEnum + Neon migrations type error
Please someone help me, I don't understand why I'm getting this error on migrations:
NeonDbError: type "roles" does not exist
at execute (D:\PROJECT\node_modules\.pnpm\@[email protected]\node_modules\@neondatabase\serverless\index.js:1555:56)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async migrate (D:\PROJECT\node_modules\.pnpm\d[email protected]_@[email protected]_@[email protected]_@[email protected]_@xat_xasefqyfafq3r2cbdr2fxaigre\node_modules\src\neon-http\migrator.ts:47:5)
at async main (D:\PROJECT\src\db\migrate.ts:14:5) {
severity: 'ERROR',
code: '42704',
detail: undefined,
hint: undefined,
position: '203',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_type.c',
line: '270',
routine: 'typenameType',
sourceError: undefined
}
NeonDbError: type "roles" does not exist
at execute (D:\PROJECT\node_modules\.pnpm\@[email protected]\node_modules\@neondatabase\serverless\index.js:1555:56)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async migrate (D:\PROJECT\node_modules\.pnpm\d[email protected]_@[email protected]_@[email protected]_@[email protected]_@xat_xasefqyfafq3r2cbdr2fxaigre\node_modules\src\neon-http\migrator.ts:47:5)
at async main (D:\PROJECT\src\db\migrate.ts:14:5) {
severity: 'ERROR',
code: '42704',
detail: undefined,
hint: undefined,
position: '203',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_type.c',
line: '270',
routine: 'typenameType',
sourceError: undefined
}
This is my user schema:
import { createId } from "@paralleldrive/cuid2";
import {
AnyPgColumn,
boolean,
pgEnum,
pgTable,
text,
timestamp,
uniqueIndex,
varchar,
} from "drizzle-orm/pg-core";

export const RoleEnum = pgEnum("roles", ["user", "admin"]);

export const users = pgTable(
"user",
{
id: text("id")
.notNull()
.primaryKey()
.$defaultFn(() => createId()),

name: varchar("name", { length: 320 }),

email: varchar("email", { length: 320 }).notNull().unique(),
password: varchar("password", { length: 255 }),

emailVerified: timestamp("emailVerified", { mode: "date" }),

image: text("image"),

role: RoleEnum("roles").default("user"),

twoFactorEnabled: boolean("twoFactorEnabled").default(false),

customerID: text("customerID"),

createdAt: timestamp("created_at").defaultNow(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
})
import { createId } from "@paralleldrive/cuid2";
import {
AnyPgColumn,
boolean,
pgEnum,
pgTable,
text,
timestamp,
uniqueIndex,
varchar,
} from "drizzle-orm/pg-core";

export const RoleEnum = pgEnum("roles", ["user", "admin"]);

export const users = pgTable(
"user",
{
id: text("id")
.notNull()
.primaryKey()
.$defaultFn(() => createId()),

name: varchar("name", { length: 320 }),

email: varchar("email", { length: 320 }).notNull().unique(),
password: varchar("password", { length: 255 }),

emailVerified: timestamp("emailVerified", { mode: "date" }),

image: text("image"),

role: RoleEnum("roles").default("user"),

twoFactorEnabled: boolean("twoFactorEnabled").default(false),

customerID: text("customerID"),

createdAt: timestamp("created_at").defaultNow(),
},
(table) => ({
emailUniqueIndex: uniqueIndex("emailUniqueIndex").on(lower(table.email)),
})
8 replies