Skip to content

Missing Error Handling in Authentication Middleware #72

Description

@beetle-ai

ISSUE_NUMBER: GH-5

Description

The isAuthenticated middleware in middlewares/auth.js lacks proper error handling. When an error occurs during token verification or user lookup, the error is only logged to the console, and the client receives no indication of an authentication failure.
File: repositories/QuestionBankapi/middlewares/auth.js
Line: 16
Severity: high

Current Behavior

Errors during token verification or user lookup are only logged to the console.

Expected Behavior

The middleware should send an error response to the client when an error occurs.

Suggested Fix

Modify the catch block to send an appropriate error response to the client.

Code Context

} catch (error) {
console.log(error);
}

Additional Notes

This can lead to unexpected behavior and a poor user experience, as the client might not be aware that authentication has failed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions