diff options
author | 2020-04-02 14:22:55 +0200 | |
---|---|---|
committer | 2020-04-02 14:22:55 +0200 | |
commit | 2ff924e0cc3494489abf0853080f316cc009e18a (patch) | |
tree | a6bb51f77c126f6174a595dda0dbfbfd03b006c8 /app/Controllers/Http/UserController.js | |
parent | Add new home page (diff) | |
parent | Merge pull request #22 from getferdi/dependabot/npm_and_yarn/acorn-7.1.1 (diff) | |
download | ferdium-server-2ff924e0cc3494489abf0853080f316cc009e18a.tar.gz ferdium-server-2ff924e0cc3494489abf0853080f316cc009e18a.tar.zst ferdium-server-2ff924e0cc3494489abf0853080f316cc009e18a.zip |
Merge branch 'master' of https://github.com/getferdi/ferdi-server
Diffstat (limited to 'app/Controllers/Http/UserController.js')
-rw-r--r-- | app/Controllers/Http/UserController.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js index edfccf2..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', |
@@ -155,17 +162,17 @@ class UserController { | |||
155 | async updateMe({ | 162 | async updateMe({ |
156 | request, | 163 | request, |
157 | response, | 164 | response, |
158 | auth | 165 | auth, |
159 | }) { | 166 | }) { |
160 | let settings = auth.user.settings || {}; | 167 | let settings = auth.user.settings || {}; |
161 | if (typeof settings === 'string') { | 168 | if (typeof settings === 'string') { |
162 | settings = JSON.parse(settings); | 169 | settings = JSON.parse(settings); |
163 | } | 170 | } |
164 | 171 | ||
165 | let newSettings = { | 172 | const newSettings = { |
166 | ...settings, | 173 | ...settings, |
167 | ...request.all(), | 174 | ...request.all(), |
168 | } | 175 | }; |
169 | 176 | ||
170 | auth.user.settings = JSON.stringify(newSettings); | 177 | auth.user.settings = JSON.stringify(newSettings); |
171 | await auth.user.save(); | 178 | await auth.user.save(); |
@@ -188,7 +195,7 @@ class UserController { | |||
188 | }, | 195 | }, |
189 | status: [ | 196 | status: [ |
190 | 'data-updated', | 197 | 'data-updated', |
191 | ] | 198 | ], |
192 | }); | 199 | }); |
193 | } | 200 | } |
194 | 201 | ||
@@ -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', |