From 26b08e510e6361b5711e0a68144201be34e31bd3 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 24 Sep 2024 17:43:28 +0530 Subject: [PATCH] feat: use hashPassword function --- server/src/models/User.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/models/User.ts b/server/src/models/User.ts index 8e944e2c..878c5656 100644 --- a/server/src/models/User.ts +++ b/server/src/models/User.ts @@ -1,6 +1,7 @@ import { DataTypes, Model, Optional } from 'sequelize'; import bcrypt from 'bcrypt'; import sequelize from '../db/config'; +import { hashPassword } from '../utils/auth'; interface UserAttributes { id: number; @@ -47,8 +48,7 @@ User.init( hooks: { beforeCreate: async (user: User) => { if (user.password) { - const salt = await bcrypt.genSalt(10); - user.password = await bcrypt.hash(user.password, salt); + user.password = await hashPassword(user.password) as string; } }, },