Skip to content

Comments

Reject passwords with leading/trailing whitespace in registration#34

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-user-authentication-issue
Draft

Reject passwords with leading/trailing whitespace in registration#34
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-user-authentication-issue

Conversation

Copy link

Copilot AI commented Feb 10, 2026

Passwords with leading or trailing whitespace were accepted during registration, creating authentication issues when login flows handle whitespace inconsistently.

Changes

  • Frontend validation (UserRegistrationForm.tsx): Reject passwords where password !== password.trim()
  • Backend validation (route.ts): Return 400 with clear error for whitespace-padded passwords
  • Test coverage (route.test.ts): Validate whitespace handling, including passwords with internal spaces (permitted)
// Frontend validation
if (formData.password !== formData.password.trim()) {
  newErrors.password = 'Password cannot have leading or trailing spaces';
}

// Backend validation  
if (password !== password.trim()) {
  return NextResponse.json(
    { error: 'Password cannot have leading or trailing spaces' },
    { status: 400 }
  );
}

Internal spaces remain valid (e.g., "my pass word" is accepted, " password " is rejected).

Original prompt

?


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix user authentication issue on login page Reject passwords with leading/trailing whitespace in registration Feb 10, 2026
}

// Validate password does not have leading or trailing whitespace
if (password !== password.trim()) {

Check failure

Code scanning / Bearer

Observable Timing Discrepancy Error

Observable Timing Discrepancy
} else if (formData.password.length < 8) {
newErrors.password = 'Password must be at least 8 characters';
} else if (formData.password !== formData.password.trim()) {
newErrors.password = 'Password cannot have leading or trailing spaces';

Check failure

Code scanning / Bearer

Usage of hard-coded secret Error

Usage of hard-coded secret
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.

2 participants