diff --git a/apps/hub/app/(app)/admin/user/action.ts b/apps/hub/app/(app)/admin/user/action.ts index 59663168..4ade5733 100644 --- a/apps/hub/app/(app)/admin/user/action.ts +++ b/apps/hub/app/(app)/admin/user/action.ts @@ -15,7 +15,7 @@ export const editUser = async (id: string, data: Prisma.UserUpdateInput) => { export const resetPassword = async (id: string) => { const password = Math.random().toString(36).slice(-8); - const hashedPassword = await bcrypt.hash(password, 15); + const hashedPassword = await bcrypt.hash(password, 12); const user = await prisma.user.update({ where: { diff --git a/apps/hub/app/(app)/settings/actions.ts b/apps/hub/app/(app)/settings/actions.ts index a5d50ed4..194c228d 100644 --- a/apps/hub/app/(app)/settings/actions.ts +++ b/apps/hub/app/(app)/settings/actions.ts @@ -1,56 +1,56 @@ -'use server'; -import { prisma, Prisma, PrismaClient } from '@repo/db'; -import { getServerSession } from '../../api/auth/[...nextauth]/auth'; -import bcrypt from 'bcryptjs'; +"use server"; +import { prisma, Prisma, PrismaClient } from "@repo/db"; +import { getServerSession } from "../../api/auth/[...nextauth]/auth"; +import bcrypt from "bcryptjs"; export const unlinkDiscord = async (userId: string) => { - const client = new PrismaClient(); - await client.discordAccount.deleteMany({ - where: { - userId, - }, - }); + const client = new PrismaClient(); + await client.discordAccount.deleteMany({ + where: { + userId, + }, + }); }; export const updateUser = async (changes: Prisma.UserUpdateInput) => { - const session = await getServerSession(); - if (!session) return null; + const session = await getServerSession(); + if (!session) return null; - const client = new PrismaClient(); + const client = new PrismaClient(); - await client.user.update({ - where: { - id: session.user.id, - }, - data: changes, - }); + await client.user.update({ + where: { + id: session.user.id, + }, + data: changes, + }); }; export const changePassword = async ( - oldPassword: string, - newPassword: string + oldPassword: string, + newPassword: string, ) => { - const session = await getServerSession(); - if (!session) - return { - error: 'User not found', - }; + const session = await getServerSession(); + if (!session) + return { + error: "User not found", + }; - if (!(await bcrypt.compare(oldPassword, session.user.password))) - return { - error: 'Old password is incorrect', - }; + if (!(await bcrypt.compare(oldPassword, session.user.password))) + return { + error: "Old password is incorrect", + }; - const hashedPassword = await bcrypt.hash(newPassword, 15); - await prisma.user.update({ - data: { - password: hashedPassword, - }, - where: { - id: session.user.id, - }, - }); - return { - success: true, - }; + const hashedPassword = await bcrypt.hash(newPassword, 12); + await prisma.user.update({ + data: { + password: hashedPassword, + }, + where: { + id: session.user.id, + }, + }); + return { + success: true, + }; }; diff --git a/apps/hub/app/(auth)/passwort-reset/action.ts b/apps/hub/app/(auth)/passwort-reset/action.ts index 663da93e..f4c17585 100644 --- a/apps/hub/app/(auth)/passwort-reset/action.ts +++ b/apps/hub/app/(auth)/passwort-reset/action.ts @@ -17,7 +17,7 @@ export const resetPassword = async (email: string) => { } const password = Math.random().toString(36).slice(-8); - const hashedPassword = await bcrypt.hash(password, 15); + const hashedPassword = await bcrypt.hash(password, 12); await prisma.user.update({ where: { email, diff --git a/apps/hub/app/(auth)/register/action.ts b/apps/hub/app/(auth)/register/action.ts index 1afeb7ac..141e3869 100644 --- a/apps/hub/app/(auth)/register/action.ts +++ b/apps/hub/app/(auth)/register/action.ts @@ -1,32 +1,32 @@ -'use server'; -import { prisma, Prisma } from '@repo/db'; -import bcrypt from 'bcryptjs'; +"use server"; +import { prisma, Prisma } from "@repo/db"; +import bcrypt from "bcryptjs"; export const register = async ({ - password, - ...user -}: Omit) => { - const hashedPassword = await bcrypt.hash(password, 15); - const lastUserPublicId = await prisma.user.findFirst({ - select: { - publicId: true, - }, - orderBy: { - publicId: 'desc', - }, - }); - let varPublicId = 'VAR0000'; - if (lastUserPublicId) { - const lastUserInt = parseInt(lastUserPublicId.publicId.replace('VAR', '')); - varPublicId = `VAR${(lastUserInt + 1).toString().padStart(4, '0')}`; - } + password, + ...user +}: Omit) => { + const hashedPassword = await bcrypt.hash(password, 12); + const lastUserPublicId = await prisma.user.findFirst({ + select: { + publicId: true, + }, + orderBy: { + publicId: "desc", + }, + }); + let varPublicId = "VAR0000"; + if (lastUserPublicId) { + const lastUserInt = parseInt(lastUserPublicId.publicId.replace("VAR", "")); + varPublicId = `VAR${(lastUserInt + 1).toString().padStart(4, "0")}`; + } - const newUser = prisma.user.create({ - data: { - ...user, - publicId: varPublicId, - password: hashedPassword, - }, - }); - return newUser; + const newUser = prisma.user.create({ + data: { + ...user, + publicId: varPublicId, + password: hashedPassword, + }, + }); + return newUser; };