Use response handler in handleErrors middleare

This commit is contained in:
Alex Holliday committed 2025-01-19 20:14:03 -08:00
1 parent e9eadfe838
commit 9f43336a03
4 files changed
+11 -5

No files matched your search

+4 -1
View File
@@ -153,7 +153,9 @@ class AuthController {
// Compare password
const match = await user.comparePassword(password);
if (match !== true) {
next(new Error(errorMessages.AUTH_INCORRECT_PASSWORD));
const error = new Error(errorMessages.AUTH_INCORRECT_PASSWORD);
error.status = 401;
next(error);
return;
}
@@ -182,6 +184,7 @@ class AuthController {
},
});
} catch (error) {
error.status = 401;
next(handleError(error, SERVICE_NAME, "loginUser"));
}
};