fix(auth): persist current_year when creating a student account#284
Merged
Merged
Conversation
Fixes omkarhole#277 The student signup path validated current_year (checking it is between 1 and 6) but never included the field in the student_bio object passed to User.create. Every student account was stored with current_year as undefined even though the client submitted a value and the schema supports the field. Added current_year: Number(req.body.current_year) to the student_bio object so the validated value is written to the database.
|
@anshul23102 is attempting to deploy a commit to the omkarhole's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Related Issue
Closes #277
Problem
The student signup path validated
current_year(range 1 to 6) but the field was absent from thestudent_bioobject passed toUser.create:Every student account was stored with
current_yearasundefinedin the database even though the client submitted a valid value and thestudentBioSchemaincludes the field.Fix
Added
current_year: Number(req.body.current_year)to thestudent_bioobject.Number()is used for consistency with the numeric type expected by the schema.Files Changed
backend/controllers/auth.controller.jscurrent_yearfield tostudent_bioinUser.createTesting
userType: student,current_year: 3. The saved document hasstudent_bio.current_year === 3.current_yearin thestudent_biopayload, so frontend consumers will now receive the correct value.Could you please add appropriate labels to this PR? It would help with tracking. Thank you!