CoreID/app/models/auth/MFAToken.model.js

26 lines
526 B
JavaScript
Raw Normal View History

2020-04-22 21:56:39 +00:00
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