users controller improvements
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user