aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Bennett <hello@vantezzen.io>2020-03-10 15:11:03 +0100
committerLibravatar Bennett <hello@vantezzen.io>2020-03-10 15:11:03 +0100
commitbca1ffbd601a19245717752df9f312172aaa3bf8 (patch)
tree6c73a7554d651de1fcc3fb04c11868675c2d858d
parentMerge branch 'master' of https://github.com/getferdi/server (diff)
downloadferdium-server-bca1ffbd601a19245717752df9f312172aaa3bf8.tar.gz
ferdium-server-bca1ffbd601a19245717752df9f312172aaa3bf8.tar.zst
ferdium-server-bca1ffbd601a19245717752df9f312172aaa3bf8.zip
Add "IS_REGISTRATION_ENABLED" option
-rw-r--r--.env.example1
-rw-r--r--.gitignore3
-rw-r--r--README.md4
-rw-r--r--app/Controllers/Http/DashboardController.js1
-rw-r--r--app/Controllers/Http/UserController.js14
5 files changed, 20 insertions, 3 deletions
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
19HASH_DRIVER=bcrypt 19HASH_DRIVER=bcrypt
20 20
21IS_CREATION_ENABLED=true 21IS_CREATION_ENABLED=true
22IS_REGISTRATION_ENABLED=true
22CONNECT_WITH_FRANZ=true \ No newline at end of file 23CONNECT_WITH_FRANZ=true \ No newline at end of file
diff --git a/.gitignore b/.gitignore
index f0a5147..12fc024 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,4 +19,5 @@ public/terms.html
19public/privacy.html 19public/privacy.html
20 20
21resources/announcements/*.json 21resources/announcements/*.json
22!resources/announcements/version.json \ No newline at end of file 22!resources/announcements/version.json
23npm-debug.log
diff --git a/README.md b/README.md
index 6aa2d02..9b39460 100644
--- a/README.md
+++ b/README.md
@@ -76,7 +76,8 @@ After setting up the docker container we recommend you to set up an NGINX revers
76 - DB_PASSWORD=<yourdbpass> 76 - DB_PASSWORD=<yourdbpass>
77 - DB_DATABASE=<yourdbdatabase> 77 - DB_DATABASE=<yourdbdatabase>
78 - IS_CREATION_ENABLED=true/false 78 - IS_CREATION_ENABLED=true/false
79 - CONNECT_WITH_FRANZ=true/flase 79 - CONNECT_WITH_FRANZ=true/false
80 - IS_REGISTRATION_ENABLED=true/false
80 volumes: 81 volumes:
81 - <path to data>:/config 82 - <path to data>:/config
82 - <path to database>:/usr/src/app/database 83 - <path to database>:/usr/src/app/database
@@ -106,6 +107,7 @@ For more information on configuring the Docker image, visit the Docker image rep
106## Configuration 107## Configuration
107franz-server's configuration is saved inside the `.env` file. Besides AdonisJS's settings, ferdi-server has the following custom settings: 108franz-server's configuration is saved inside the `.env` file. Besides AdonisJS's settings, ferdi-server has the following custom settings:
108- `IS_CREATION_ENABLED` (`true` or `false`, default: `true`): Whether to enable the [creation of custom recipes](#creating-and-using-custom-recipes) 109- `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
109- `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, ferdi-server can: 111- `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, ferdi-server can:
110 - Show the full Franz recipe library instead of only custom recipes 112 - Show the full Franz recipe library instead of only custom recipes
111 - Import Franz accounts 113 - Import Franz accounts
diff --git a/app/Controllers/Http/DashboardController.js b/app/Controllers/Http/DashboardController.js
index 1018f78..86cfa74 100644
--- a/app/Controllers/Http/DashboardController.js
+++ b/app/Controllers/Http/DashboardController.js
@@ -181,7 +181,6 @@ class DashboardController {
181 session.flash({ type: 'danger', message: 'Invalid Ferdi account file' }); 181 session.flash({ type: 'danger', message: 'Invalid Ferdi account file' });
182 return response.redirect('back'); 182 return response.redirect('back');
183 } 183 }
184 console.log(file);
185 184
186 if (!file || !file.services || !file.workspaces) { 185 if (!file || !file.services || !file.workspaces) {
187 session.flash({ type: 'danger', message: 'Invalid Ferdi account file (2)' }); 186 session.flash({ type: 'danger', message: 'Invalid Ferdi account file (2)' });
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js
index 979e78a..e580e49 100644
--- a/app/Controllers/Http/UserController.js
+++ b/app/Controllers/Http/UserController.js
@@ -38,6 +38,13 @@ class UserController {
38 response, 38 response,
39 auth, 39 auth,
40 }) { 40 }) {
41 if (Env.get('IS_REGISTRATION_ENABLED') == 'false') { // eslint-disable-line eqeqeq
42 return response.status(401).send({
43 message: 'Registration is disabled on this server',
44 status: 401,
45 });
46 }
47
41 // Validate user input 48 // Validate user input
42 const validation = await validateAll(request.all(), { 49 const validation = await validateAll(request.all(), {
43 firstname: 'required', 50 firstname: 'required',
@@ -197,6 +204,13 @@ class UserController {
197 request, 204 request,
198 response, 205 response,
199 }) { 206 }) {
207 if (Env.get('IS_REGISTRATION_ENABLED') == 'false') { // eslint-disable-line eqeqeq
208 return response.status(401).send({
209 message: 'Registration is disabled on this server',
210 status: 401,
211 });
212 }
213
200 // Validate user input 214 // Validate user input
201 const validation = await validateAll(request.all(), { 215 const validation = await validateAll(request.all(), {
202 email: 'required|email|unique:users,email', 216 email: 'required|email|unique:users,email',