Reduce bcrypt iterations from 15 to 12 (common for 2025 processors)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<Prisma.UserCreateInput, 'publicId'>) => {
|
||||
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<Prisma.UserCreateInput, "publicId">) => {
|
||||
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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user