CoreID/app/controllers/Home.controller.js
garrettmills 60003d64d5
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Add front-end error logging
2020-10-28 19:13:13 -05:00

41 lines
1.1 KiB
JavaScript

const Controller = require('libflitter/controller/Controller')
/*
* Home Controller
* -------------------------------------------------------------
* Controller for the main homepage of this Flitter app. Methods here
* are used as handlers for routes specified in the route files.
*/
class Home extends Controller {
static get services() {
return [...super.services, 'Vue', 'models']
}
/*
* Serve the main welcome page.
*/
async welcome(req, res){
const Setting = this.models.get('Setting')
if ( await Setting.get('home.allow_landing') && !(req.user && await Setting.get('home.redirect_authenticated')) ) {
return res.page('welcome', {
user: req.user,
...this.Vue.data(),
})
}
return res.redirect('/dash')
}
async tmpl(req, res) {
return res.page('tmpl', {...this.Vue.data(), ...this.Vue.session(req)})
}
async log_front_end_error(req, res, next) {
const FrontEndError = this.models.get('FrontEndError')
await FrontEndError.log(req)
return res.api()
}
}
module.exports = Home