-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance JWT Token Management #102
Conversation
@Harshdev098 please review this pr and add necessary tags(hacktoberfest and gssoc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its giving error, I think its because you have changed the parameters of the generateAccessToken
and decodeAccessToken
, and its very overwhelming to update these functions in every files, if there is any other method to add the middleware you can go with it, or discard the changes done for setting the middleware checkKey
because i think its not that necessary
OR you can update the functions in the files |
@Harshdev098 i think refactoring the code will cause too much issue in the future , let me try to simplify and change the code according to your needs |
Yah, right |
@Harshdev098 check if this is good enough or not and let me know |
Fixed Issue #99
Changes Made to the codebase
1. Added Middleware for Environment Variable Validation
Introduced a checkKey middleware function to validate the presence of ACCESS_TOKEN_SECRET in environment variables
and assign it to req.Key for use in subsequent functions.
2. Refactored generateAccessToken Function
Improved error handling with specific messages for token generation failure and server errors.
Returned the token as a JSON object with a clear key.
3. Improved decodeAccessToken Function
Streamlined error checking for the authorization header.
Removed redundant checks and ensured the function handles decoding the token appropriately.
Returned error messages with appropriate status codes for missing authorization headers, token decoding failures, and invalid or expired tokens.
4. Consistent Error Responses
Ensured that all error responses are formatted consistently with proper status codes and messages.