CoreID/app/controllers/auth/Forms.controller.js
garrettmills 9729de47f8
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing
Make registration carry flow all the way through
2021-05-03 20:06:51 -05:00

54 lines
1.6 KiB
JavaScript

const FormController = require('flitter-auth/controllers/Forms')
/*
* Handles views and processing for auth registration/login/logout/etc.
* Most handlers are inherited from the default flitter-auth/controllers/Forms
* controller, however you can override them here as you need.
*/
class Forms extends FormController {
static get services() {
return [...super.services, 'Vue', 'models']
}
async registration_provider_get(req, res, next) {
if ( req.session.auth.flow ) {
req.session.registrant_flow = req.session.auth.flow
}
return res.page('auth:register', {
...this.Vue.data({})
})
}
async finish_registration(req, res, next) {
if ( req.trap.has_trap() && req.trap.get_trap() === 'registrant_flow' ) await req.trap.end()
const dest = req.session.registrant_flow || '/dash/profile'
return res.redirect(dest)
}
async login_provider_get(req, res, next) {
const Setting = this.models.get('Setting')
return res.page('auth:login', {
...this.Vue.data({
login_message: req.session?.auth?.message || req.T('auth.sign_in_to_continue'),
registration_enabled: await Setting.get('auth.allow_registration')
}),
})
}
async logout_provider_present_success(req, res, next) {
return this.Vue.auth_message(res, {
message: req.T('auth.logged_out'),
next_destination: '/',
})
}
async logout_provider_clean_session(req, res, next) {
await req.user.logout(req)
return next()
}
}
module.exports = exports = Forms