Skip to content
Permalink
Browse files

Add "IS_DASHBOARD_ENABLED" option

  • Loading branch information
vantezzen committed Mar 10, 2020
1 parent a26ea30 commit 6664abb0fe0f8e75e605d8344a6434b2bdf57ca2
Showing with 29 additions and 20 deletions.
  1. +1 −0 .env.example
  2. +2 −0 README.md
  3. +0 −2 app/Middleware/HandleDoubleSlash.js
  4. +26 −18 start/routes.js
@@ -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
@@ -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:
- <path to data>:/config
- <path to database>:/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
@@ -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(
@@ -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');

0 comments on commit 6664abb

Please sign in to comment.
You can’t perform that action at this time.