Refactoring user Page in admin panel.

This commit is contained in:
charlesgauthereau
2025-12-30 13:38:01 +01:00
parent 8e3eb32631
commit c18a9da0d3
31 changed files with 1032 additions and 252 deletions
+34
View File
@@ -0,0 +1,34 @@
import {SignUpUser} from "@/types/auth";
import {hashPassword} from "better-auth/crypto";
import {db} from "@/db";
import * as drizzleDb from "@/db";
import {User, UserThemeEnum} from "@/db/schema/02_user";
export async function createUserDb(data: SignUpUser): Promise<User> {
const now = new Date();
const hashedPassword = await hashPassword(data.password);
const userId = crypto.randomUUID();
const [newUser] = await db.insert(drizzleDb.schemas.user).values({
id: userId,
name: data.name,
email: data.email,
emailVerified: true,
role: data.role,
createdAt: now,
updatedAt: now,
theme: data.theme as UserThemeEnum,
}).returning();
await db.insert(drizzleDb.schemas.account).values({
providerId: "credential",
accountId: userId,
userId: userId,
password: hashedPassword,
createdAt: now,
updatedAt: now,
});
return newUser
}