From e1144681575256580697bb254ffd3a76c2d03719 Mon Sep 17 00:00:00 2001 From: Kevsl Date: Tue, 18 Jun 2024 21:40:41 +0200 Subject: [PATCH] tryed to remove bcrypt for bcryptjs --- src/auth/auth.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 616934c..cddcdf7 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -1,7 +1,8 @@ import { ForbiddenException, Injectable } from '@nestjs/common'; import { PrismaService } from '../prisma/prisma.service'; import { AuthLoginDto, AuthRegisterDto } from './dto'; -import * as argon from 'argon2'; +import bcrypt from 'bcryptjs'; + import { Prisma, User } from '@prisma/client'; import { JwtService } from '@nestjs/jwt'; import { ConfigService } from '@nestjs/config'; @@ -15,7 +16,7 @@ export class AuthService { ) {} async signup(dto: AuthRegisterDto) { - const hash = await argon.hash(dto.password); + const hash = await bcrypt.hashSync(dto.password); const promoCode = await this.prisma.promoCode.findFirst({ where: { name: dto.promoCode, @@ -73,7 +74,8 @@ export class AuthService { }); if (!userDatas) throw new ForbiddenException('Credentials incorrect'); - const pwMatches = await argon.verify(userDatas.hash, dto.password); + const pwMatches = await bcrypt.compareSync(userDatas.hash, dto.password); + if (!pwMatches) throw new ForbiddenException('Credentials incorrect'); return this.signToken(userDatas);