From bca1ffbd601a19245717752df9f312172aaa3bf8 Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 10 Mar 2020 15:11:03 +0100 Subject: Add "IS_REGISTRATION_ENABLED" option --- .env.example | 1 + 1 file changed, 1 insertion(+) (limited to '.env.example') diff --git a/.env.example b/.env.example index c175cd1..f4e828b 100644 --- a/.env.example +++ b/.env.example @@ -19,4 +19,5 @@ DB_DATABASE=adonis HASH_DRIVER=bcrypt IS_CREATION_ENABLED=true +IS_REGISTRATION_ENABLED=true CONNECT_WITH_FRANZ=true \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 6664abb0fe0f8e75e605d8344a6434b2bdf57ca2 Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 10 Mar 2020 15:44:29 +0100 Subject: Add "IS_DASHBOARD_ENABLED" option --- .env.example | 1 + README.md | 2 ++ app/Middleware/HandleDoubleSlash.js | 2 -- start/routes.js | 44 ++++++++++++++++++++++--------------- 4 files changed, 29 insertions(+), 20 deletions(-) (limited to '.env.example') diff --git a/.env.example b/.env.example index f4e828b..bcc4c7c 100644 --- a/.env.example +++ b/.env.example @@ -19,5 +19,6 @@ DB_DATABASE=adonis HASH_DRIVER=bcrypt IS_CREATION_ENABLED=true +IS_DASHBOARD_ENABLED=true IS_REGISTRATION_ENABLED=true CONNECT_WITH_FRANZ=true \ No newline at end of file diff --git a/README.md b/README.md index 9b39460..99afc94 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ After setting up the docker container we recommend you to set up an NGINX revers - IS_CREATION_ENABLED=true/false - CONNECT_WITH_FRANZ=true/false - IS_REGISTRATION_ENABLED=true/false + - IS_DASHBOARD_ENABLED=true/false volumes: - :/config - :/usr/src/app/database @@ -108,6 +109,7 @@ For more information on configuring the Docker image, visit the Docker image rep franz-server's configuration is saved inside the `.env` file. Besides AdonisJS's settings, ferdi-server has the following custom settings: - `IS_CREATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the [creation of custom recipes](#creating-and-using-custom-recipes) - `IS_REGISTRATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the creation of new user accounts +- `IS_DASHBOARD_ENABLED` (`true` or `false`, default: `true`): Whether to enable the user dashboard - `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, ferdi-server can: - Show the full Franz recipe library instead of only custom recipes - Import Franz accounts diff --git a/app/Middleware/HandleDoubleSlash.js b/app/Middleware/HandleDoubleSlash.js index 94f4fe8..456b774 100644 --- a/app/Middleware/HandleDoubleSlash.js +++ b/app/Middleware/HandleDoubleSlash.js @@ -10,8 +10,6 @@ class HandleDoubleSlash { * @param {Function} next */ async handle ({ request, response }, next) { - console.log(request.url()); - // Redirect requests that contain duplicate slashes to the right path if (request.url().includes('//')) { return response.redirect( diff --git a/start/routes.js b/start/routes.js index b5674fd..6385ca5 100644 --- a/start/routes.js +++ b/start/routes.js @@ -60,24 +60,32 @@ Route.group(() => { }).prefix('v1'); // User dashboard -Route.group(() => { - // Auth - Route.get('login', ({ view }) => view.render('dashboard.login')).middleware('guest'); - Route.post('login', 'DashboardController.login').middleware('guest'); - - // Dashboard - Route.get('account', 'DashboardController.account').middleware('auth:session'); - Route.post('account', 'DashboardController.edit').middleware('auth:session'); - Route.get('data', 'DashboardController.data').middleware('auth:session'); - Route.get('export', 'DashboardController.export').middleware('auth:session'); - Route.post('transfer', 'DashboardController.import').middleware('auth:session'); - Route.get('transfer', ({ view }) => view.render('dashboard.transfer')).middleware('auth:session'); - Route.get('delete', ({ view }) => view.render('dashboard.delete')).middleware('auth:session'); - Route.post('delete', 'DashboardController.delete').middleware('auth:session'); - Route.get('logout', 'DashboardController.logout').middleware('auth:session'); - - Route.get('*', ({ response }) => response.redirect('/user/account')); -}).prefix('user').middleware('shield'); +if (Env.get('IS_DASHBOARD_ENABLED') != 'false') { + Route.group(() => { + // Auth + Route.get('login', ({ view }) => view.render('dashboard.login')).middleware('guest'); + Route.post('login', 'DashboardController.login').middleware('guest'); + + // Dashboard + Route.get('account', 'DashboardController.account').middleware('auth:session'); + Route.post('account', 'DashboardController.edit').middleware('auth:session'); + Route.get('data', 'DashboardController.data').middleware('auth:session'); + Route.get('export', 'DashboardController.export').middleware('auth:session'); + Route.post('transfer', 'DashboardController.import').middleware('auth:session'); + Route.get('transfer', ({ view }) => view.render('dashboard.transfer')).middleware('auth:session'); + Route.get('delete', ({ view }) => view.render('dashboard.delete')).middleware('auth:session'); + Route.post('delete', 'DashboardController.delete').middleware('auth:session'); + Route.get('logout', 'DashboardController.logout').middleware('auth:session'); + + Route.get('*', ({ response }) => response.redirect('/user/account')); + }).prefix('user').middleware('shield'); +} else { + Route.group(() => { + Route.get('*', ({ + response, + }) => response.send('The user dashboard is disabled on this server\n\nIf you are the server owner, please set IS_DASHBOARD_ENABLED to true to enable the dashboard.')) + }).prefix('user'); +} // Recipe creation Route.post('new', 'RecipeController.create'); -- cgit v1.2.3-54-g00ecf