Retrieves the JWT token:
It checks for the token in both cookies and the Authorization header.Validates the token:
It verifies the token using the secret key stored in the environment variable JWT_SECRET.Fetches the user or captain:
It uses the decoded token ID to find the corresponding user in the database.Attaches the user or captain object:
If the user is found, it attaches the user object to the request object for further use.Handles errors:
It catches any errors that occur during the process and sends an appropriate error response.Posted Feb 7, 2025
Contribute to Subhojit0012/uber development by creating an account on GitHub.
0
1