From 6caf39276323afef0ba5734f4782ab05fff3517a Mon Sep 17 00:00:00 2001 From: V S Tharunika <1vstharu279@gmail.com> Date: Sun, 27 Dec 2020 13:37:18 +0530 Subject: [PATCH] added 'AuthenticationController' file to handle the user input in registration process --- .../controllers/AuthenticationController.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/server/src/controllers/AuthenticationController.js b/server/src/controllers/AuthenticationController.js index 1caaa279..dcc129d4 100644 --- a/server/src/controllers/AuthenticationController.js +++ b/server/src/controllers/AuthenticationController.js @@ -1,9 +1,17 @@ +const {User}= require('../models') + + module.exports={ - register(req, res){ - - res.send({ - message: 'hello ${req.body.email} ! Your user was registered! Have fun!' - - }) + async register(req, res){ + + try{ + const user= await User.create(req.body) + res.send(user.toJSON()) + }catch (err){ + res.status(400).send({ + error: 'This email account is already in use.' + }) + } + } } \ No newline at end of file -- GitLab