From fafc238e701c74f7a524a762865fc2302674fc40 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 9 Feb 2025 18:56:17 -0600 Subject: [PATCH] refactor: migration --- apps/dokploy/drizzle/0066_broad_marrow.sql | 25 +++++++++- apps/dokploy/package.json | 2 +- apps/dokploy/pages/index.tsx | 47 +++++++++++-------- apps/dokploy/pages/register.tsx | 36 ++++++++------ apps/dokploy/server/api/routers/admin.ts | 2 +- packages/server/auth-schema.ts | 4 +- packages/server/src/db/schema/account.ts | 4 +- packages/server/src/db/schema/auth.ts | 4 +- packages/server/src/db/schema/certificate.ts | 8 ++-- packages/server/src/db/schema/destination.ts | 8 ++-- packages/server/src/db/schema/git-provider.ts | 8 ++-- packages/server/src/db/schema/notification.ts | 8 ++-- packages/server/src/db/schema/project.ts | 8 ++-- packages/server/src/db/schema/registry.ts | 8 ++-- packages/server/src/db/schema/server.ts | 8 ++-- packages/server/src/db/schema/session.ts | 4 +- packages/server/src/db/schema/ssh-key.ts | 8 ++-- packages/server/src/db/schema/user.ts | 6 +-- packages/server/src/lib/auth.ts | 3 +- packages/server/src/services/admin.ts | 2 +- packages/server/src/services/auth.ts | 2 +- packages/server/src/services/user.ts | 34 +++++++------- 22 files changed, 138 insertions(+), 101 deletions(-) diff --git a/apps/dokploy/drizzle/0066_broad_marrow.sql b/apps/dokploy/drizzle/0066_broad_marrow.sql index f1085414..d7e3acf0 100644 --- a/apps/dokploy/drizzle/0066_broad_marrow.sql +++ b/apps/dokploy/drizzle/0066_broad_marrow.sql @@ -90,7 +90,8 @@ UPDATE "user" SET token = '' WHERE token IS NULL; UPDATE "user" SET "expirationDate" = CURRENT_TIMESTAMP + INTERVAL '1 year' WHERE "expirationDate" IS NULL; UPDATE "user" SET "createdAt" = to_char(CURRENT_TIMESTAMP, 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') WHERE "createdAt" IS NULL; UPDATE "user" SET "name" = '' WHERE "name" IS NULL; -UPDATE "user" SET "email" = COALESCE("email", '') WHERE true; +-- Generar emails Ășnicos para registros vacĂ­os +UPDATE "user" SET "email" = CONCAT('user_', id, '@dokploy.local') WHERE "email" = '' OR "email" IS NULL; UPDATE "user" SET "email_verified" = COALESCE("email_verified", false) WHERE true; UPDATE "user" SET "role" = COALESCE("role", 'user') WHERE true; UPDATE "user" SET "banned" = COALESCE("banned", false) WHERE true; @@ -128,6 +129,28 @@ SELECT CAST("createdAt" AS timestamp) as updated_at FROM "auth"; +-- Migrar datos de auth a account +INSERT INTO "account" ( + id, + account_id, + provider_id, + user_id, + password, + "is2FAEnabled", + created_at, + updated_at +) +SELECT + id as id, + id as account_id, + 'credentials' as provider_id, + id as user_id, + password, + "is2FAEnabled", + CAST("createdAt" AS timestamp) as created_at, + CAST("createdAt" AS timestamp) as updated_at +FROM "auth"; + -- Migrar datos de admin a user UPDATE "user" u SET diff --git a/apps/dokploy/package.json b/apps/dokploy/package.json index e2a7c4a2..9e531cf8 100644 --- a/apps/dokploy/package.json +++ b/apps/dokploy/package.json @@ -35,7 +35,7 @@ "test": "vitest --config __test__/vitest.config.ts" }, "dependencies": { - "better-auth":"1.1.16", + "better-auth": "1.1.16", "bl": "6.0.11", "rotating-file-stream": "3.2.3", "qrcode": "^1.5.3", diff --git a/apps/dokploy/pages/index.tsx b/apps/dokploy/pages/index.tsx index 3aafe9bf..2691fc5c 100644 --- a/apps/dokploy/pages/index.tsx +++ b/apps/dokploy/pages/index.tsx @@ -13,6 +13,7 @@ import { FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; +import { authClient } from "@/lib/auth"; import { cn } from "@/lib/utils"; import { api } from "@/utils/api"; import { IS_CLOUD, isAdminPresent, validateRequest } from "@dokploy/server"; @@ -65,8 +66,8 @@ export default function Home({ IS_CLOUD }: Props) { const router = useRouter(); const form = useForm({ defaultValues: { - email: "", - password: "", + email: "siumauricio@hotmail.com", + password: "Password1234", }, resolver: zodResolver(loginSchema), }); @@ -76,25 +77,31 @@ export default function Home({ IS_CLOUD }: Props) { }, [form, form.reset, form.formState.isSubmitSuccessful]); const onSubmit = async (values: Login) => { - await mutateAsync({ - email: values.email.toLowerCase(), + const { data, error } = await authClient.signIn.email({ + email: values.email, password: values.password, - }) - .then((data) => { - if (data.is2FAEnabled) { - setTemp(data); - } else { - toast.success("Successfully signed in", { - duration: 2000, - }); - router.push("/dashboard/projects"); - } - }) - .catch(() => { - toast.error("Signin failed", { - duration: 2000, - }); - }); + }); + + console.log(data, error); + // await mutateAsync({ + // email: values.email.toLowerCase(), + // password: values.password, + // }) + // .then((data) => { + // if (data.is2FAEnabled) { + // setTemp(data); + // } else { + // toast.success("Successfully signed in", { + // duration: 2000, + // }); + // router.push("/dashboard/projects"); + // } + // }) + // .catch(() => { + // toast.error("Signin failed", { + // duration: 2000, + // }); + // }); }; return ( <> diff --git a/apps/dokploy/pages/register.tsx b/apps/dokploy/pages/register.tsx index e42231a2..4ff3d4da 100644 --- a/apps/dokploy/pages/register.tsx +++ b/apps/dokploy/pages/register.tsx @@ -17,6 +17,7 @@ import { FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; +import { authClient } from "@/lib/auth"; import { api } from "@/utils/api"; import { IS_CLOUD, isAdminPresent, validateRequest } from "@dokploy/server"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -79,9 +80,9 @@ const Register = ({ isCloud }: Props) => { const form = useForm({ defaultValues: { - email: "", - password: "", - confirmPassword: "", + email: "user5@yopmail.com", + password: "Password1234", + confirmPassword: "Password1234", }, resolver: zodResolver(registerSchema), }); @@ -91,19 +92,24 @@ const Register = ({ isCloud }: Props) => { }, [form, form.reset, form.formState.isSubmitSuccessful]); const onSubmit = async (values: Register) => { - await mutateAsync({ - email: values.email.toLowerCase(), + const { data, error } = await authClient.signUp.email({ + email: values.email, password: values.password, - }) - .then(() => { - toast.success("User registered successfuly", { - duration: 2000, - }); - if (!isCloud) { - router.push("/"); - } - }) - .catch((e) => e); + name: "Mauricio Siu", + }); + // await mutateAsync({ + // email: values.email.toLowerCase(), + // password: values.password, + // }) + // .then(() => { + // toast.success("User registered successfuly", { + // duration: 2000, + // }); + // if (!isCloud) { + // router.push("/"); + // } + // }) + // .catch((e) => e); }; return (
diff --git a/apps/dokploy/server/api/routers/admin.ts b/apps/dokploy/server/api/routers/admin.ts index 31612fe0..6a4764f5 100644 --- a/apps/dokploy/server/api/routers/admin.ts +++ b/apps/dokploy/server/api/routers/admin.ts @@ -6,7 +6,7 @@ import { apiRemoveUser, apiUpdateAdmin, apiUpdateWebServerMonitoring, - users, + user, } from "@/server/db/schema"; import { IS_CLOUD, diff --git a/packages/server/auth-schema.ts b/packages/server/auth-schema.ts index 8f8be24d..8865078b 100644 --- a/packages/server/auth-schema.ts +++ b/packages/server/auth-schema.ts @@ -1,9 +1,9 @@ import { + boolean, + integer, pgTable, text, - integer, timestamp, - boolean, } from "drizzle-orm/pg-core"; export const user = pgTable("user", { diff --git a/packages/server/src/db/schema/account.ts b/packages/server/src/db/schema/account.ts index 7117f4a4..a332ec92 100644 --- a/packages/server/src/db/schema/account.ts +++ b/packages/server/src/db/schema/account.ts @@ -1,5 +1,5 @@ import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core"; -import { users } from "./user"; +import { user } from "./user"; export const account = pgTable("account", { id: text("id").primaryKey(), @@ -7,7 +7,7 @@ export const account = pgTable("account", { providerId: text("provider_id").notNull(), userId: text("user_id") .notNull() - .references(() => users.id), + .references(() => user.id), accessToken: text("access_token"), refreshToken: text("refresh_token"), idToken: text("id_token"), diff --git a/packages/server/src/db/schema/auth.ts b/packages/server/src/db/schema/auth.ts index 7093a40c..35f4dc85 100644 --- a/packages/server/src/db/schema/auth.ts +++ b/packages/server/src/db/schema/auth.ts @@ -5,7 +5,7 @@ import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; // import { admins } from "./admin"; -import { users } from "./user"; +import { user } from "./user"; const randomImages = [ "/avatars/avatar-1.png", @@ -56,7 +56,7 @@ export const auth = pgTable("auth", { export const authRelations = relations(auth, ({ many }) => ({ // admins: many(admins), - users: many(users), + users: many(user), })); const createSchema = createInsertSchema(auth, { email: z.string().email(), diff --git a/packages/server/src/db/schema/certificate.ts b/packages/server/src/db/schema/certificate.ts index 22f4f9cb..3a7ec596 100644 --- a/packages/server/src/db/schema/certificate.ts +++ b/packages/server/src/db/schema/certificate.ts @@ -4,8 +4,8 @@ import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; import { server } from "./server"; +import { user } from "./user"; import { generateAppName } from "./utils"; -import { users } from "./user"; export const certificates = pgTable("certificate", { certificateId: text("certificateId") @@ -20,7 +20,7 @@ export const certificates = pgTable("certificate", { .$defaultFn(() => generateAppName("certificate")) .unique(), autoRenew: boolean("autoRenew"), - userId: text("userId").references(() => users.id, { + userId: text("userId").references(() => user.id, { onDelete: "cascade", }), serverId: text("serverId").references(() => server.serverId, { @@ -35,9 +35,9 @@ export const certificatesRelations = relations( fields: [certificates.serverId], references: [server.serverId], }), - user: one(users, { + user: one(user, { fields: [certificates.userId], - references: [users.id], + references: [user.id], }), }), ); diff --git a/packages/server/src/db/schema/destination.ts b/packages/server/src/db/schema/destination.ts index c89ed1e3..37faf0fa 100644 --- a/packages/server/src/db/schema/destination.ts +++ b/packages/server/src/db/schema/destination.ts @@ -5,7 +5,7 @@ import { nanoid } from "nanoid"; import { z } from "zod"; import { admins } from "./admin"; import { backups } from "./backups"; -import { users } from "./user"; +import { user } from "./user"; export const destinations = pgTable("destination", { destinationId: text("destinationId") @@ -22,16 +22,16 @@ export const destinations = pgTable("destination", { endpoint: text("endpoint").notNull(), userId: text("userId") .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), }); export const destinationsRelations = relations( destinations, ({ many, one }) => ({ backups: many(backups), - user: one(users, { + user: one(user, { fields: [destinations.userId], - references: [users.id], + references: [user.id], }), }), ); diff --git a/packages/server/src/db/schema/git-provider.ts b/packages/server/src/db/schema/git-provider.ts index 00dc928d..f044b0a0 100644 --- a/packages/server/src/db/schema/git-provider.ts +++ b/packages/server/src/db/schema/git-provider.ts @@ -7,7 +7,7 @@ import { admins } from "./admin"; import { bitbucket } from "./bitbucket"; import { github } from "./github"; import { gitlab } from "./gitlab"; -import { users } from "./user"; +import { user } from "./user"; export const gitProviderType = pgEnum("gitProviderType", [ "github", @@ -25,7 +25,7 @@ export const gitProvider = pgTable("git_provider", { createdAt: text("createdAt") .notNull() .$defaultFn(() => new Date().toISOString()), - userId: text("userId").references(() => users.id, { + userId: text("userId").references(() => user.id, { onDelete: "cascade", }), }); @@ -43,9 +43,9 @@ export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({ fields: [gitProvider.gitProviderId], references: [bitbucket.gitProviderId], }), - user: one(users, { + user: one(user, { fields: [gitProvider.userId], - references: [users.id], + references: [user.id], }), })); diff --git a/packages/server/src/db/schema/notification.ts b/packages/server/src/db/schema/notification.ts index 4b7a09ea..5174c17c 100644 --- a/packages/server/src/db/schema/notification.ts +++ b/packages/server/src/db/schema/notification.ts @@ -4,7 +4,7 @@ import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; import { admins } from "./admin"; -import { users } from "./user"; +import { user } from "./user"; export const notificationType = pgEnum("notificationType", [ "slack", @@ -45,7 +45,7 @@ export const notifications = pgTable("notification", { gotifyId: text("gotifyId").references(() => gotify.gotifyId, { onDelete: "cascade", }), - userId: text("userId").references(() => users.id, { + userId: text("userId").references(() => user.id, { onDelete: "cascade", }), }); @@ -122,9 +122,9 @@ export const notificationsRelations = relations(notifications, ({ one }) => ({ fields: [notifications.gotifyId], references: [gotify.gotifyId], }), - user: one(users, { + user: one(user, { fields: [notifications.userId], - references: [users.id], + references: [user.id], }), })); diff --git a/packages/server/src/db/schema/project.ts b/packages/server/src/db/schema/project.ts index 44036838..2602a8ec 100644 --- a/packages/server/src/db/schema/project.ts +++ b/packages/server/src/db/schema/project.ts @@ -12,7 +12,7 @@ import { mongo } from "./mongo"; import { mysql } from "./mysql"; import { postgres } from "./postgres"; import { redis } from "./redis"; -import { users } from "./user"; +import { user } from "./user"; export const projects = pgTable("project", { projectId: text("projectId") @@ -26,7 +26,7 @@ export const projects = pgTable("project", { .$defaultFn(() => new Date().toISOString()), userId: text("userId") .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), env: text("env").notNull().default(""), }); @@ -38,9 +38,9 @@ export const projectRelations = relations(projects, ({ many, one }) => ({ mongo: many(mongo), redis: many(redis), compose: many(compose), - user: one(users, { + user: one(user, { fields: [projects.userId], - references: [users.id], + references: [user.id], }), })); diff --git a/packages/server/src/db/schema/registry.ts b/packages/server/src/db/schema/registry.ts index d1f79068..166168c5 100644 --- a/packages/server/src/db/schema/registry.ts +++ b/packages/server/src/db/schema/registry.ts @@ -5,7 +5,7 @@ import { nanoid } from "nanoid"; import { z } from "zod"; import { admins } from "./admin"; import { applications } from "./application"; -import { users } from "./user"; +import { user } from "./user"; /** * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same * database instance for multiple projects. @@ -30,13 +30,13 @@ export const registry = pgTable("registry", { registryType: registryType("selfHosted").notNull().default("cloud"), userId: text("userId") .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), }); export const registryRelations = relations(registry, ({ one, many }) => ({ - user: one(users, { + user: one(user, { fields: [registry.userId], - references: [users.id], + references: [user.id], }), applications: many(applications), })); diff --git a/packages/server/src/db/schema/server.ts b/packages/server/src/db/schema/server.ts index 71d6ca08..e3a14f95 100644 --- a/packages/server/src/db/schema/server.ts +++ b/packages/server/src/db/schema/server.ts @@ -22,8 +22,8 @@ import { mysql } from "./mysql"; import { postgres } from "./postgres"; import { redis } from "./redis"; import { sshKeys } from "./ssh-key"; +import { user } from "./user"; import { generateAppName } from "./utils"; -import { users } from "./user"; export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]); @@ -46,7 +46,7 @@ export const server = pgTable("server", { .$defaultFn(() => new Date().toISOString()), userId: text("userId") .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => user.id, { onDelete: "cascade" }), serverStatus: serverStatus("serverStatus").notNull().default("active"), command: text("command").notNull().default(""), sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, { @@ -101,9 +101,9 @@ export const server = pgTable("server", { }); export const serverRelations = relations(server, ({ one, many }) => ({ - user: one(users, { + user: one(user, { fields: [server.userId], - references: [users.id], + references: [user.id], }), deployments: many(deployments), sshKey: one(sshKeys, { diff --git a/packages/server/src/db/schema/session.ts b/packages/server/src/db/schema/session.ts index 396e8194..e7d579fb 100644 --- a/packages/server/src/db/schema/session.ts +++ b/packages/server/src/db/schema/session.ts @@ -1,5 +1,5 @@ import { pgTable, text, timestamp } from "drizzle-orm/pg-core"; -import { users } from "./user"; +import { user } from "./user"; // OLD TABLE export const sessionTable = pgTable("session", { @@ -12,6 +12,6 @@ export const sessionTable = pgTable("session", { userAgent: text("user_agent"), userId: text("user_id") .notNull() - .references(() => users.id), + .references(() => user.id), impersonatedBy: text("impersonated_by"), }); diff --git a/packages/server/src/db/schema/ssh-key.ts b/packages/server/src/db/schema/ssh-key.ts index 7a4f5061..6c5ba0a7 100644 --- a/packages/server/src/db/schema/ssh-key.ts +++ b/packages/server/src/db/schema/ssh-key.ts @@ -7,7 +7,7 @@ import { admins } from "./admin"; import { applications } from "./application"; import { compose } from "./compose"; import { server } from "./server"; -import { users } from "./user"; +import { user } from "./user"; export const sshKeys = pgTable("ssh-key", { sshKeyId: text("sshKeyId") @@ -22,7 +22,7 @@ export const sshKeys = pgTable("ssh-key", { .notNull() .$defaultFn(() => new Date().toISOString()), lastUsedAt: text("lastUsedAt"), - userId: text("userId").references(() => users.id, { + userId: text("userId").references(() => user.id, { onDelete: "cascade", }), }); @@ -31,9 +31,9 @@ export const sshKeysRelations = relations(sshKeys, ({ many, one }) => ({ applications: many(applications), compose: many(compose), servers: many(server), - user: one(users, { + user: one(user, { fields: [sshKeys.userId], - references: [users.id], + references: [user.id], }), })); diff --git a/packages/server/src/db/schema/user.ts b/packages/server/src/db/schema/user.ts index 473cf190..372b79f8 100644 --- a/packages/server/src/db/schema/user.ts +++ b/packages/server/src/db/schema/user.ts @@ -14,7 +14,7 @@ import { certificateType } from "./shared"; */ // OLD TABLE -export const users = pgTable("user", { +export const user = pgTable("user", { id: text("id") .notNull() .primaryKey() @@ -129,7 +129,7 @@ export const users = pgTable("user", { .default(false), }); -export const usersRelations = relations(users, ({ one }) => ({ +export const usersRelations = relations(user, ({ one }) => ({ // auth: one(auth, { // fields: [users.authId], // references: [auth.id], @@ -140,7 +140,7 @@ export const usersRelations = relations(users, ({ one }) => ({ // }), })); -const createSchema = createInsertSchema(users, { +const createSchema = createInsertSchema(user, { id: z.string().min(1), // authId: z.string().min(1), token: z.string().min(1), diff --git a/packages/server/src/lib/auth.ts b/packages/server/src/lib/auth.ts index fada2c43..93eed4ca 100644 --- a/packages/server/src/lib/auth.ts +++ b/packages/server/src/lib/auth.ts @@ -2,10 +2,11 @@ import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { admin } from "better-auth/plugins"; import { db } from "../db"; - +import * as schema from "../db/schema"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", + schema: schema, }), emailAndPassword: { enabled: true, diff --git a/packages/server/src/services/admin.ts b/packages/server/src/services/admin.ts index 056b8178..ea0df9b0 100644 --- a/packages/server/src/services/admin.ts +++ b/packages/server/src/services/admin.ts @@ -4,7 +4,7 @@ import { admins, type apiCreateUserInvitation, auth, - users, + user, } from "@dokploy/server/db/schema"; import { TRPCError } from "@trpc/server"; import * as bcrypt from "bcrypt"; diff --git a/packages/server/src/services/auth.ts b/packages/server/src/services/auth.ts index 65a01c41..376f10e9 100644 --- a/packages/server/src/services/auth.ts +++ b/packages/server/src/services/auth.ts @@ -5,7 +5,7 @@ import { type apiCreateAdmin, type apiCreateUser, auth, - users, + user, } from "@dokploy/server/db/schema"; import { getPublicIpWithFallback } from "@dokploy/server/wss/utils"; import { TRPCError } from "@trpc/server"; diff --git a/packages/server/src/services/user.ts b/packages/server/src/services/user.ts index d8d9862c..f50e678a 100644 --- a/packages/server/src/services/user.ts +++ b/packages/server/src/services/user.ts @@ -1,15 +1,15 @@ import { db } from "@dokploy/server/db"; -import { users } from "@dokploy/server/db/schema"; +import { user } from "@dokploy/server/db/schema"; import { TRPCError } from "@trpc/server"; import { eq } from "drizzle-orm"; -export type User = typeof users.$inferSelect; +export type User = typeof user.$inferSelect; export const findUserById = async (userId: string) => { - const user = await db.query.users.findFirst({ - where: eq(users.userId, userId), + const userR = await db.query.user.findFirst({ + where: eq(user.userId, userId), }); - if (!user) { + if (!userR) { throw new TRPCError({ code: "NOT_FOUND", message: "User not found", @@ -19,8 +19,8 @@ export const findUserById = async (userId: string) => { }; export const findUserByAuthId = async (authId: string) => { - const user = await db.query.users.findFirst({ - where: eq(users.authId, authId), + const userR = await db.query.user.findFirst({ + where: eq(user.authId, authId), with: { auth: true, }, @@ -35,8 +35,8 @@ export const findUserByAuthId = async (authId: string) => { }; export const findUsers = async (adminId: string) => { - const currentUsers = await db.query.users.findMany({ - where: eq(users.adminId, adminId), + const currentUsers = await db.query.user.findMany({ + where: eq(user.adminId, adminId), with: { auth: { columns: { @@ -49,24 +49,24 @@ export const findUsers = async (adminId: string) => { }; export const addNewProject = async (authId: string, projectId: string) => { - const user = await findUserByAuthId(authId); + const userR = await findUserByAuthId(authId); await db - .update(users) + .update(user) .set({ - accessedProjects: [...user.accessedProjects, projectId], + accessedProjects: [...userR.accessedProjects, projectId], }) - .where(eq(users.authId, authId)); + .where(eq(user.authId, authId)); }; export const addNewService = async (authId: string, serviceId: string) => { - const user = await findUserByAuthId(authId); + const userR = await findUserByAuthId(authId); await db - .update(users) + .update(user) .set({ - accessedServices: [...user.accessedServices, serviceId], + accessedServices: [...userR.accessedServices, serviceId], }) - .where(eq(users.authId, authId)); + .where(eq(user.authId, authId)); }; export const canPerformCreationService = async (