You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CoreID/app/models/auth/PasswordReset.model.js

25 lines
622 B

const { Model } = require('flitter-orm')
const bcrypt = require('bcrypt')
class PasswordResetModel extends Model {
static get schema() {
return {
reset_on: { type: Date, default: () => new Date },
old_hash: String,
hash: String,
reason: { type: String, default: 'user' }, // 'user' | 'lockout'
}
}
async set_hash(password) {
this.hash = await bcrypt.hash(password, 10)
return this
}
async check(password) {
return await bcrypt.compare(password, this.hash)
}
}
module.exports = exports = PasswordResetModel