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.
45 lines
1.4 KiB
45 lines
1.4 KiB
const { Controller } = require('libflitter')
|
|
|
|
class MFAController extends Controller {
|
|
static get services() {
|
|
return [...super.services, 'Vue', 'configs']
|
|
}
|
|
|
|
async setup(req, res, next) {
|
|
if ( req.user.mfa_enabled ) {
|
|
// Already set up!
|
|
return this.Vue.auth_message(res, {
|
|
message: 'It looks like your account is already set up for multi-factor authentication. Unable to continue with MFA setup.',
|
|
next_destination: '/', // TODO update this
|
|
button_text: 'Okay',
|
|
})
|
|
}
|
|
|
|
// Display the token setup page
|
|
return res.page('auth:mfa:setup', {
|
|
...this.Vue.data()
|
|
})
|
|
}
|
|
|
|
async challenge(req, res, next) {
|
|
if ( !req.user.mfa_enabled ) {
|
|
return this.Vue.auth_message(res, {
|
|
message: 'Your account is not configured to use multi-factor authentication. Would you like to configure it now?',
|
|
next_destination: '/auth/mfa/setup',
|
|
button_text: 'Setup MFA',
|
|
})
|
|
}
|
|
|
|
if ( !req.session.auth.in_dmz ) {
|
|
return res.redirect(req.session.auth.flow)
|
|
}
|
|
|
|
// Display the MFA challenge page
|
|
return res.page('auth:mfa:challenge', {
|
|
...this.Vue.data()
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = exports = MFAController
|