CoreID/app/models/auth/AppPassword.model.js
garrettmills cf91063315
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is failing
#9 - show app password use date in profile
2021-12-14 16:40:15 -06:00

30 lines
768 B
JavaScript

const { Model } = require('flitter-orm')
const bcrypt = require('bcrypt')
const uuid = require('uuid').v4
class AppPasswordModel extends Model {
static get schema() {
return {
hash: String,
created: { type: Date, default: () => new Date },
accessed: Date,
expires: Date,
active: { type: Boolean, default: true },
name: String,
uuid: { type: String, default: uuid },
}
}
async set_hash(password) {
this.hash = await bcrypt.hash(password, 10)
if ( !this.uuid ) this.uuid = uuid()
return this
}
async verify(password) {
return bcrypt.compare(password, this.hash)
}
}
module.exports = exports = AppPasswordModel