diff --git a/server/controllers/authController.js b/server/controllers/authController.js index a697b72..c2beb88 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, }); @@ -180,22 +179,17 @@ 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 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 +209,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..f19cc88 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,12 +475,20 @@ paths: schema: type: object properties: - success: - $ref: "#/components/schemas/SuccessFalseStatus" message: 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: @@ -490,8 +496,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 +511,6 @@ paths: schema: type: object properties: - success: - $ref: "#/components/schemas/SuccessFalseStatus" message: $ref: '#/components/schemas/InternalErrorMessage'