diff options
-rw-r--r-- | .env.example | 1 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | app/Middleware/HandleDoubleSlash.js | 2 | ||||
-rw-r--r-- | start/routes.js | 44 |
4 files changed, 29 insertions, 20 deletions
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 | |||
19 | HASH_DRIVER=bcrypt | 19 | HASH_DRIVER=bcrypt |
20 | 20 | ||
21 | IS_CREATION_ENABLED=true | 21 | IS_CREATION_ENABLED=true |
22 | IS_DASHBOARD_ENABLED=true | ||
22 | IS_REGISTRATION_ENABLED=true | 23 | IS_REGISTRATION_ENABLED=true |
23 | CONNECT_WITH_FRANZ=true \ No newline at end of file | 24 | CONNECT_WITH_FRANZ=true \ No newline at end of file |
@@ -78,6 +78,7 @@ After setting up the docker container we recommend you to set up an NGINX revers | |||
78 | - IS_CREATION_ENABLED=true/false | 78 | - IS_CREATION_ENABLED=true/false |
79 | - CONNECT_WITH_FRANZ=true/false | 79 | - CONNECT_WITH_FRANZ=true/false |
80 | - IS_REGISTRATION_ENABLED=true/false | 80 | - IS_REGISTRATION_ENABLED=true/false |
81 | - IS_DASHBOARD_ENABLED=true/false | ||
81 | volumes: | 82 | volumes: |
82 | - <path to data>:/config | 83 | - <path to data>:/config |
83 | - <path to database>:/usr/src/app/database | 84 | - <path to database>:/usr/src/app/database |
@@ -108,6 +109,7 @@ For more information on configuring the Docker image, visit the Docker image rep | |||
108 | franz-server's configuration is saved inside the `.env` file. Besides AdonisJS's settings, ferdi-server has the following custom settings: | 109 | franz-server's configuration is saved inside the `.env` file. Besides AdonisJS's settings, ferdi-server has the following custom settings: |
109 | - `IS_CREATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the [creation of custom recipes](#creating-and-using-custom-recipes) | 110 | - `IS_CREATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the [creation of custom recipes](#creating-and-using-custom-recipes) |
110 | - `IS_REGISTRATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the creation of new user accounts | 111 | - `IS_REGISTRATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the creation of new user accounts |
112 | - `IS_DASHBOARD_ENABLED` (`true` or `false`, default: `true`): Whether to enable the user dashboard | ||
111 | - `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, ferdi-server can: | 113 | - `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, ferdi-server can: |
112 | - Show the full Franz recipe library instead of only custom recipes | 114 | - Show the full Franz recipe library instead of only custom recipes |
113 | - Import Franz accounts | 115 | - 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 { | |||
10 | * @param {Function} next | 10 | * @param {Function} next |
11 | */ | 11 | */ |
12 | async handle ({ request, response }, next) { | 12 | async handle ({ request, response }, next) { |
13 | console.log(request.url()); | ||
14 | |||
15 | // Redirect requests that contain duplicate slashes to the right path | 13 | // Redirect requests that contain duplicate slashes to the right path |
16 | if (request.url().includes('//')) { | 14 | if (request.url().includes('//')) { |
17 | return response.redirect( | 15 | 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(() => { | |||
60 | }).prefix('v1'); | 60 | }).prefix('v1'); |
61 | 61 | ||
62 | // User dashboard | 62 | // User dashboard |
63 | Route.group(() => { | 63 | if (Env.get('IS_DASHBOARD_ENABLED') != 'false') { |
64 | // Auth | 64 | Route.group(() => { |
65 | Route.get('login', ({ view }) => view.render('dashboard.login')).middleware('guest'); | 65 | // Auth |
66 | Route.post('login', 'DashboardController.login').middleware('guest'); | 66 | Route.get('login', ({ view }) => view.render('dashboard.login')).middleware('guest'); |
67 | 67 | Route.post('login', 'DashboardController.login').middleware('guest'); | |
68 | // Dashboard | 68 | |
69 | Route.get('account', 'DashboardController.account').middleware('auth:session'); | 69 | // Dashboard |
70 | Route.post('account', 'DashboardController.edit').middleware('auth:session'); | 70 | Route.get('account', 'DashboardController.account').middleware('auth:session'); |
71 | Route.get('data', 'DashboardController.data').middleware('auth:session'); | 71 | Route.post('account', 'DashboardController.edit').middleware('auth:session'); |
72 | Route.get('export', 'DashboardController.export').middleware('auth:session'); | 72 | Route.get('data', 'DashboardController.data').middleware('auth:session'); |
73 | Route.post('transfer', 'DashboardController.import').middleware('auth:session'); | 73 | Route.get('export', 'DashboardController.export').middleware('auth:session'); |
74 | Route.get('transfer', ({ view }) => view.render('dashboard.transfer')).middleware('auth:session'); | 74 | Route.post('transfer', 'DashboardController.import').middleware('auth:session'); |
75 | Route.get('delete', ({ view }) => view.render('dashboard.delete')).middleware('auth:session'); | 75 | Route.get('transfer', ({ view }) => view.render('dashboard.transfer')).middleware('auth:session'); |
76 | Route.post('delete', 'DashboardController.delete').middleware('auth:session'); | 76 | Route.get('delete', ({ view }) => view.render('dashboard.delete')).middleware('auth:session'); |
77 | Route.get('logout', 'DashboardController.logout').middleware('auth:session'); | 77 | Route.post('delete', 'DashboardController.delete').middleware('auth:session'); |
78 | 78 | Route.get('logout', 'DashboardController.logout').middleware('auth:session'); | |
79 | Route.get('*', ({ response }) => response.redirect('/user/account')); | 79 | |
80 | }).prefix('user').middleware('shield'); | 80 | Route.get('*', ({ response }) => response.redirect('/user/account')); |
81 | }).prefix('user').middleware('shield'); | ||
82 | } else { | ||
83 | Route.group(() => { | ||
84 | Route.get('*', ({ | ||
85 | response, | ||
86 | }) => 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.')) | ||
87 | }).prefix('user'); | ||
88 | } | ||
81 | 89 | ||
82 | // Recipe creation | 90 | // Recipe creation |
83 | Route.post('new', 'RecipeController.create'); | 91 | Route.post('new', 'RecipeController.create'); |