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)}) } } module.exports = Home