Skip to content

fix(contracts): enforce password complexity requirements on update endpoint (@d1rshan)#7977

Open
d1rshan wants to merge 2 commits into
monkeytypegame:masterfrom
d1rshan:fix/users-schema
Open

fix(contracts): enforce password complexity requirements on update endpoint (@d1rshan)#7977
d1rshan wants to merge 2 commits into
monkeytypegame:masterfrom
d1rshan:fix/users-schema

Conversation

@d1rshan
Copy link
Copy Markdown
Contributor

@d1rshan d1rshan commented May 19, 2026

The backend UpdatePasswordRequestSchema only enforced z.string().min(6), while the frontend PasswordSchema requires min 8, max 64, uppercase, number, and special character. This allowed weak passwords to be set via direct API calls, bypassing frontend validation.

Updated the backend contract to use PasswordSchema from @monkeytype/schemas/users, ensuring consistent validation across frontend and backend.

Copilot AI review requested due to automatic review settings May 19, 2026 18:33
@monkeytypegeorge monkeytypegeorge added backend Server stuff packages Changes in local packages labels May 19, 2026
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label May 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR aligns the update-password request contract and controller tests with a shared PasswordSchema, enabling stronger/centralized password validation rules.

Changes:

  • Replaced inline z.string().min(6) validation with PasswordSchema for UpdatePasswordRequestSchema.
  • Updated user controller password-update tests to use a password that meets the new complexity requirements.
  • Updated expected validation error messages for invalid password submissions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/contracts/src/users.ts Switches update-password validation to the shared PasswordSchema contract.
backend/tests/api/controllers/user.spec.ts Updates test inputs and expected validation errors to match the new password policy.

Comment thread backend/__tests__/api/controllers/user.spec.ts
Comment thread backend/__tests__/api/controllers/user.spec.ts
Comment thread backend/__tests__/api/controllers/user.spec.ts
@fehmer
Copy link
Copy Markdown
Member

fehmer commented May 19, 2026

Afair the password is still validated by the firebase rules, but it doesnt hurt to check on our api as well

@github-actions github-actions Bot removed the waiting for review Pull requests that require a review before continuing label May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server stuff packages Changes in local packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants