CoreID/app/controllers/Home.controller.js

35 lines
981 B
JavaScript
Raw Normal View History

2020-04-16 20:38:01 +00:00
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() {
2020-08-24 14:38:48 +00:00
return [...super.services, 'Vue', 'models']
}
2020-04-16 20:38:01 +00:00
/*
* Serve the main welcome page.
*/
2020-08-24 14:38:48 +00:00
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')) ) {
2020-08-24 14:38:48 +00:00
return res.page('welcome', {
user: req.user,
...this.Vue.data(),
})
}
2020-04-16 20:38:01 +00:00
2020-08-24 14:38:48 +00:00
return res.redirect('/dash')
}
async tmpl(req, res) {
2020-05-04 01:16:54 +00:00
return res.page('tmpl', {...this.Vue.data(), ...this.Vue.session(req)})
2020-04-16 20:38:01 +00:00
}
}
module.exports = Home