bcrypt como servicio y login operador listo

This commit is contained in:
xXpuma99Xx
2022-04-21 17:49:08 -05:00
parent ede4bbd0dc
commit e5610f0dd3
7 changed files with 71 additions and 14 deletions
+20
View File
@@ -0,0 +1,20 @@
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import * as bcrypt from 'bcrypt';
@Injectable()
export class BcryptService {
constructor(private configService: ConfigService) {}
encriptar(password: string) {
const salt = bcrypt.genSaltSync(
Number(this.configService.get<string>('SALT_ROUNDS')),
);
return bcrypt.hashSync(password, salt);
}
comparar(password: string, passwordDb: string) {
return bcrypt.compareSync(password, passwordDb);
}
}