CoreID/app/models/auth/MFAToken.model.js
2020-04-22 16:56:39 -05:00

26 lines
526 B
JavaScript

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