refactor(auth): extract authentication request validation into dedica…#825
Open
jikrana1 wants to merge 1 commit into
Open
refactor(auth): extract authentication request validation into dedica…#825jikrana1 wants to merge 1 commit into
jikrana1 wants to merge 1 commit into
Conversation
|
Someone is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel. A member of the Team first needs to authorize it. |
Userunknown84
left a comment
Owner
There was a problem hiding this comment.
I see the changes that you shift that code to a particular file but the code removed from the existing files i show here and not see the files where the code is shifted but call the file in authroutes.js i see.
…ted validator middleware (Closes Userunknown84#805)
11758c0 to
a1ace7a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #805
Problem description
The
authRoutes.jsfile currently performed request validation directly inside the route definition, mixing validation logic with routing responsibilities. Additionally, the route file was inadvertently bloated with duplicate controller logic. This made the file large, unmaintainable, and violated the separation of concerns principle.Proposed solution
Cleaned up
authRoutes.jsto strictly handle routing and applied dedicated validation middlewares.Implementation details:
authRoutes.js. (All controllers are now imported from../controllers/authController.js).registerValidation,loginValidation,forgotPasswordValidation,resetPasswordValidation) to the respective routes.protectmiddleware for protected endpoints.Benefits
Testing instructions
400 Bad Request./api/auth/mewithout authentication. It should return a401 Unauthorized.