From 10e448b02580e819f4c6acecd6b92d0c32b1d391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Geonizeli?= Date: Sun, 10 Jul 2022 10:35:47 -0300 Subject: [PATCH] users controller improvements --- server/src/controller/user.controller.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/controller/user.controller.ts b/server/src/controller/user.controller.ts index b5982fe..68b6515 100644 --- a/server/src/controller/user.controller.ts +++ b/server/src/controller/user.controller.ts @@ -15,7 +15,9 @@ router.post(apiNamespace, (req, res) => { password, }) .then(() => { - res.json(); + res.json({ + success: true, + }); }) .catch((err) => { res.status(422).json({ @@ -29,6 +31,13 @@ router.post(`${apiNamespace}/sign_in`, async (req, res) => { const user = await UserService.findByEmail(email); + if (!user) { + res.status(500).json({ + error: "Invalid credentails", + }); + return; + } + const isPasswordValid = await AuthService.isUserPasswordValid(user, password); if (isPasswordValid) {