Skip to content

Fix User pre-save hook and add automated test suite - #69

Merged
kumar-veerendra merged 2 commits into
mainfrom
fix/code-execution-bugfix
Aug 31, 2026
Merged

kumar-veerendra merged 2 commits into
mainfrom
fix/code-execution-bugfix

Conversation

@kumar-veerendra

Copy link
Copy Markdown
Owner

This pull request introduces a new test suite to verify and benchmark the User model's pre-save password hashing logic, and makes a minor improvement to the pre-save middleware for clarity and reliability.

Testing improvements:

  • Added backend/tests/test_user_presave.js, a comprehensive test script that:
    • Verifies password hashing on registration, password update, and stats-only updates.
    • Ensures that password hashes are only recalculated when the password is actually changed.
    • Benchmarks the latency of the pre-save hook to prevent unnecessary bcrypt hashing during unrelated updates.

Code quality improvement:

  • In backend/models/User.js, updated the pre-save middleware to explicitly return after calling next() when the password is unmodified, preventing any further execution in the middleware.

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kumar-veerendra-nqtcoder Ready Ready Preview Aug 31, 2026 2:11pm

@kumar-veerendra
kumar-veerendra merged commit 8a6821f into main Aug 31, 2026
2 checks passed

This branch was successfully deployed

1 active deployment
Preview — 2aff3947 Deployed Aug 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant