From e83d5c8c80ef6193a6748925f1e07f00368cd133 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Sat, 27 Dec 2025 22:47:11 +0100 Subject: [PATCH 1/3] REMOVE success attribute from response in login-related responses --- server/controllers/authController.js | 4 ---- swagger.yaml | 8 -------- 2 files changed, 12 deletions(-) diff --git a/server/controllers/authController.js b/server/controllers/authController.js index a697b72..e6dd448 100644 --- a/server/controllers/authController.js +++ b/server/controllers/authController.js @@ -172,7 +172,6 @@ export const checkSession = async (req, res) => { export const loginLocal = async (req, res, next) => { if (req.sanitizedErrors) { return res.status(422).json({ - success: false, message: 'Analysis could not be created due to validation errors', errors: req.sanitizedErrors, }); @@ -188,14 +187,12 @@ export const loginLocal = async (req, res, next) => { if (!user) { //* Will trigger if user does not exist return res.status(401).json({ - success: false, message: 'The combination of email and password is incorrect', }); } if (user.role === 'participant') { return res.status(403).json({ - success: false, message: 'Participant login is disabled', }); } @@ -215,7 +212,6 @@ export const loginLocal = async (req, res, next) => { updateUserLastLoginDate(user.id); // Fire-and-forget function return res.status(200).json({ - success: true, message: 'Login successful', user: { id: user.id, diff --git a/swagger.yaml b/swagger.yaml index bc56fb1..5642935 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -458,8 +458,6 @@ paths: schema: type: object properties: - success: - $ref: "#/components/schemas/SuccessTrueStatus" message: type: string example: Login successful @@ -477,8 +475,6 @@ paths: schema: type: object properties: - success: - $ref: "#/components/schemas/SuccessFalseStatus" message: type: string example: The combination of email and password is incorrect @@ -490,8 +486,6 @@ paths: schema: type: object properties: - success: - $ref: "#/components/schemas/SuccessFalseStatus" message: type: string example: User could not be created due to validation errors @@ -507,8 +501,6 @@ paths: schema: type: object properties: - success: - $ref: "#/components/schemas/SuccessFalseStatus" message: $ref: '#/components/schemas/InternalErrorMessage' From e7d469aa5532f671ceef51163f4645dd5c43d3e8 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Sat, 27 Dec 2025 22:47:26 +0100 Subject: [PATCH 2/3] ADD missing 403 response to login swagger docs --- swagger.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/swagger.yaml b/swagger.yaml index 5642935..f19cc88 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -479,6 +479,16 @@ paths: type: string example: The combination of email and password is incorrect + 403: + description: Participant login is disabled + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: Participant login is disabled 422: description: Validation error content: From 6311a0e6a41adc8194d56e1d9c6d4d6cc42eb816 Mon Sep 17 00:00:00 2001 From: Sergio N Date: Sat, 27 Dec 2025 22:48:06 +0100 Subject: [PATCH 3/3] REFACTOR login error response to use the global error handler --- server/controllers/authController.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/controllers/authController.js b/server/controllers/authController.js index e6dd448..c2beb88 100644 --- a/server/controllers/authController.js +++ b/server/controllers/authController.js @@ -179,10 +179,7 @@ export const loginLocal = async (req, res, next) => { return passport.authenticate('local', (err, user /* , info */) => { if (err) { - return res.status(500).json({ - success: false, - message: 'An error occurred during login', - }); + return next(err); } if (!user) { //* Will trigger if user does not exist