users controller improvements

This commit is contained in:
João Geonizeli
2022-07-10 10:35:47 -03:00
parent 8eda61aad8
commit 10e448b025

View File

@@ -15,7 +15,9 @@ router.post(apiNamespace, (req, res) => {
password, password,
}) })
.then(() => { .then(() => {
res.json(); res.json({
success: true,
});
}) })
.catch((err) => { .catch((err) => {
res.status(422).json({ res.status(422).json({
@@ -29,6 +31,13 @@ router.post(`${apiNamespace}/sign_in`, async (req, res) => {
const user = await UserService.findByEmail(email); const user = await UserService.findByEmail(email);
if (!user) {
res.status(500).json({
error: "Invalid credentails",
});
return;
}
const isPasswordValid = await AuthService.isUserPasswordValid(user, password); const isPasswordValid = await AuthService.isUserPasswordValid(user, password);
if (isPasswordValid) { if (isPasswordValid) {