login usuario

This commit is contained in:
arturo
2020-08-19 09:34:11 -05:00
parent 38eca663e0
commit b5aee47e60
7 changed files with 1010 additions and 13 deletions
+14
View File
@@ -1,3 +1,5 @@
import * as bcrypt from 'bcrypt'
import {
Entity,
PrimaryGeneratedColumn,
@@ -53,6 +55,10 @@ export class Usuario {
@IsString()
institucion: string
@Column()
@IsString()
secreto: string
@Column({ type: 'date', default: '1996-11-07' })
@IsDate()
@IsOptional()
@@ -93,4 +99,12 @@ export class Usuario {
(log) => log.usuario
)
logs: Log[]
hashPassword () {
this.secreto = bcrypt.hashSync(this.secreto, 10)
}
checkIfUnencryptedPasswordIsValid (unencryptedPassword: string) {
return bcrypt.compareSync(unencryptedPassword, this.secreto)
}
}