Skip to content

fix(auth): persist current_year when creating a student account#284

Merged
omkarhole merged 1 commit into
omkarhole:mainfrom
anshul23102:fix/issue-277-current-year
Jun 3, 2026
Merged

fix(auth): persist current_year when creating a student account#284
omkarhole merged 1 commit into
omkarhole:mainfrom
anshul23102:fix/issue-277-current-year

Conversation

@anshul23102

Copy link
Copy Markdown
Contributor

Related Issue

Closes #277

Problem

The student signup path validated current_year (range 1 to 6) but the field was absent from the student_bio object passed to User.create:

student_bio: {
    gender: req.body.gender || 'male',
    enrollment_year: req.body.enrollment_year || new Date().getFullYear(),
    course: course_id,
    roll_number: req.body.roll_number || null,
    avatar: ''
    // current_year is missing
}

Every student account was stored with current_year as undefined in the database even though the client submitted a valid value and the studentBioSchema includes the field.

Fix

Added current_year: Number(req.body.current_year) to the student_bio object. Number() is used for consistency with the numeric type expected by the schema.

Files Changed

File Change
backend/controllers/auth.controller.js Add current_year field to student_bio in User.create

Testing

  • POST signup with userType: student, current_year: 3. The saved document has student_bio.current_year === 3.
  • The login response already included current_year in the student_bio payload, 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!

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.
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

@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.

@omkarhole omkarhole merged commit 9dec8aa into omkarhole:main Jun 3, 2026
0 of 2 checks passed
@omkarhole omkarhole added NSOC'26 Issues for the NSOC 2026 program level1 3 points labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level1 3 points NSOC'26 Issues for the NSOC 2026 program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: student signup validates current_year but never stores it in the database

2 participants