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.
26 lines
526 B
26 lines
526 B
4 years ago
|
const { Model } = require('flitter-orm')
|
||
|
const speakeasy = require('speakeasy')
|
||
|
|
||
|
class MFATokenModel extends Model {
|
||
|
static get services() {
|
||
|
return [...super.services, 'MFA']
|
||
|
}
|
||
|
|
||
|
static get schema() {
|
||
|
return {
|
||
|
secret: String,
|
||
|
otpauth_url: String,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
verify(value) {
|
||
|
return speakeasy.totp.verify({
|
||
|
secret: this.secret,
|
||
|
encoding: 'base32',
|
||
|
token: value,
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = exports = MFATokenModel
|