login usuario
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user