diff options
Diffstat (limited to 'app/Controllers/Http/UserController.js')
-rw-r--r-- | app/Controllers/Http/UserController.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/app/Controllers/Http/UserController.js b/app/Controllers/Http/UserController.js index 062e16f..f78f28d 100644 --- a/app/Controllers/Http/UserController.js +++ b/app/Controllers/Http/UserController.js | |||
@@ -13,11 +13,20 @@ class UserController { | |||
13 | session | 13 | session |
14 | }) { | 14 | }) { |
15 | const data = request.only(['firstname', 'email', 'password']); | 15 | const data = request.only(['firstname', 'email', 'password']); |
16 | const user = await User.create({ | 16 | |
17 | email: data.email, | 17 | try { |
18 | password: data.password, | 18 | const user = await User.create({ |
19 | username: data.firstname | 19 | email: data.email, |
20 | }); | 20 | password: data.password, |
21 | username: data.firstname | ||
22 | }); | ||
23 | } catch(e) { | ||
24 | return response.status(401).send({ | ||
25 | "message": "E-Mail Address already in use", | ||
26 | "status": 401 | ||
27 | }) | ||
28 | } | ||
29 | |||
21 | const token = await auth.generate(user) | 30 | const token = await auth.generate(user) |
22 | 31 | ||
23 | return response.send({ | 32 | return response.send({ |