SAML; Dashboard
This commit is contained in:
28
app/models/auth/AppPassword.model.js
Normal file
28
app/models/auth/AppPassword.model.js
Normal file
@@ -0,0 +1,28 @@
|
||||
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 },
|
||||
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
|
||||
Reference in New Issue
Block a user