From aeae72c01c6f1881c15391b2d60a18aa2d320030 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Mon, 24 Aug 2020 09:38:48 -0500 Subject: [PATCH] Add setting to bypass homepage --- app/controllers/Home.controller.js | 21 ++++++++++----------- app/routing/routers/index.routes.js | 3 --- config/setting.config.js | 1 + 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/controllers/Home.controller.js b/app/controllers/Home.controller.js index 17e4af6..b7f104c 100644 --- a/app/controllers/Home.controller.js +++ b/app/controllers/Home.controller.js @@ -8,23 +8,22 @@ const Controller = require('libflitter/controller/Controller') */ class Home extends Controller { static get services() { - return [...super.services, 'Vue'] + return [...super.services, 'Vue', 'models'] } /* * 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 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(), - }) + return res.redirect('/dash') } async tmpl(req, res) { diff --git a/app/routing/routers/index.routes.js b/app/routing/routers/index.routes.js index b8bc64b..949bdf2 100644 --- a/app/routing/routers/index.routes.js +++ b/app/routing/routers/index.routes.js @@ -45,9 +45,6 @@ const index = { // Placeholder for auth dashboard. You'd replace this with // your own route protected by 'middleware::auth:UserOnly' '/dash': [ 'middleware::auth:UserOnly', ['middleware::Redirect', {to: '/dash/profile'}] ], - - // TODO remove this - '/tmpl': [ 'middleware::auth:UserOnly', 'controller::Home.tmpl' ], }, /* diff --git a/config/setting.config.js b/config/setting.config.js index 4a0992c..d8227bc 100644 --- a/config/setting.config.js +++ b/config/setting.config.js @@ -2,6 +2,7 @@ const setting_config = { settings: { 'auth.allow_registration': true, 'auth.default_roles': [ 'base_user' ], + 'home.allow_landing': true, } }