Add setting to bypass homepage

This commit is contained in:
Garrett Mills 2020-08-24 09:38:48 -05:00
parent 6d402e3f81
commit aeae72c01c
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
3 changed files with 11 additions and 14 deletions

View File

@ -8,23 +8,22 @@ const Controller = require('libflitter/controller/Controller')
*/ */
class Home extends Controller { class Home extends Controller {
static get services() { static get services() {
return [...super.services, 'Vue'] return [...super.services, 'Vue', 'models']
} }
/* /*
* Serve the main welcome page. * Serve the main welcome page.
*/ */
welcome(req, res){ async welcome(req, res){
const Setting = this.models.get('Setting')
if ( await Setting.get('home.allow_landing') ) {
return res.page('welcome', {
user: req.user,
...this.Vue.data(),
})
}
/* return res.redirect('/dash')
* Return the welcome view.
* The page() method is added by Flitter and passes some
* helpful contextual data to the view as well.
*/
return res.page('welcome', {
user: req.user,
...this.Vue.data(),
})
} }
async tmpl(req, res) { async tmpl(req, res) {

View File

@ -45,9 +45,6 @@ const index = {
// Placeholder for auth dashboard. You'd replace this with // Placeholder for auth dashboard. You'd replace this with
// your own route protected by 'middleware::auth:UserOnly' // your own route protected by 'middleware::auth:UserOnly'
'/dash': [ 'middleware::auth:UserOnly', ['middleware::Redirect', {to: '/dash/profile'}] ], '/dash': [ 'middleware::auth:UserOnly', ['middleware::Redirect', {to: '/dash/profile'}] ],
// TODO remove this
'/tmpl': [ 'middleware::auth:UserOnly', 'controller::Home.tmpl' ],
}, },
/* /*

View File

@ -2,6 +2,7 @@ const setting_config = {
settings: { settings: {
'auth.allow_registration': true, 'auth.allow_registration': true,
'auth.default_roles': [ 'base_user' ], 'auth.default_roles': [ 'base_user' ],
'home.allow_landing': true,
} }
} }