Skip to content

fix: align password minlength in UI with backend validation#33

Open
bilalahmadsheikh wants to merge 1 commit intoalphaonelabs:mainfrom
bilalahmadsheikh:bilal/fix/password-minlength-mismatch
Open

fix: align password minlength in UI with backend validation#33
bilalahmadsheikh wants to merge 1 commit intoalphaonelabs:mainfrom
bilalahmadsheikh:bilal/fix/password-minlength-mismatch

Conversation

@bilalahmadsheikh
Copy link
Copy Markdown

@bilalahmadsheikh bilalahmadsheikh commented Mar 30, 2026

Changes

  • Fix password minlength attribute in registration form from 6 to 8
  • Fix placeholder text from "min 6 characters" to "min 8 characters"

Why

The backend (worker.py line 655) rejects passwords shorter than 8 characters,
but the frontend registration form allowed submissions with as few as 6 characters.
This caused confusing silent failures for users — the browser accepted their
password but the server rejected it with no clear explanation.

Testing

  • Open public/login.html in browser
  • Registration form password field now enforces minimum 8 characters client-side
  • Matches backend validation in worker.py

Summary

This PR aligns the frontend password validation with the backend validation rules by updating the registration form's password field constraints.

Changes

Updated public/login.html registration form password input:

  • Changed minlength attribute from 6 to 8 characters
  • Updated placeholder text from "min 6 characters" to "min 8 characters"

Purpose

The backend validation in worker.py enforces a minimum password length of 8 characters. However, the frontend previously allowed passwords as short as 6 characters, resulting in silent server-side rejections when users submitted passwords that passed client-side validation but failed backend checks.

Impact

This change provides immediate client-side feedback to users, preventing confusion from silent form submission failures. Users attempting to register with passwords shorter than 8 characters will now see the constraint enforced in the browser before attempting to submit, improving the registration experience.

Copilot AI review requested due to automatic review settings March 30, 2026 20:51
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Walkthrough

The password field in the login form has been updated to enforce stricter validation requirements, increasing the minimum password length from 6 to 8 characters, with the placeholder text adjusted accordingly to match this new constraint.

Changes

Cohort / File(s) Summary
Form Validation
public/login.html
Updated password input minlength constraint from 6 to 8 characters, with corresponding placeholder text updated from "min 6 characters" to "min 8 characters".

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: aligning the UI password minlength constraint with backend validation, which is exactly what the changeset accomplishes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

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

This PR aims to align the registration UI’s password requirements with the backend validation (backend requires passwords to be at least 8 characters).

Changes:

  • Updated the registration password input minlength from 6 to 8.
  • Updated the password placeholder text from “min 6 characters” to “min 8 characters”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +76 to +77
<input id="r-password" type="password" autocomplete="new-password" required minlength="8"
class="w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-brand/40 text-sm" placeholder="min 8 characters" />
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

minlength="8" won’t actually prevent submitting short passwords because the registration <form> has novalidate and the submit handler always preventDefault() + fetch() without calling checkValidity() or performing a length check. As a result, users can still submit <8 chars and only learn after the backend rejects it. Consider either removing novalidate for the register form or adding an explicit client-side validation in the submit handler (e.g., show register-err when password length < 8 before sending the request).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
public/login.html (1)

36-36: ⚠️ Potential issue | 🟠 Major

Add CSRF protection tokens to forms.

Both the login and register forms lack CSRF protection tokens. This makes the application vulnerable to Cross-Site Request Forgery attacks where a malicious site could trick authenticated users into submitting unwanted requests.

Recommendation: Implement CSRF token generation on the server side and include the token in:

  1. A hidden input field within each form
  2. The request headers or body when submitting via fetch()

Example approach:

  • Render a CSRF token in a hidden input: <input type="hidden" name="csrf_token" value="{{csrf_token}}">
  • Include it in the fetch body: { ...formData, csrf_token: document.getElementById('csrf-token').value }
  • Validate the token server-side in worker.py before processing the request

Would you like me to provide a more detailed implementation example for adding CSRF protection to this application?

As per coding guidelines: "Check that forms include CSRF protection tokens."

Also applies to: 58-58, 115-116, 130-136

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@public/login.html` at line 36, Add server-generated CSRF tokens to both forms
(e.g., the form element with id "form-login" and the register form) by rendering
a hidden input named "csrf_token" (and an id like "csrf-token") into
public/login.html and the corresponding register HTML; ensure client-side submit
handlers include that token in the fetch body or request header when sending the
form; finally add token verification in the server request handlers in worker.py
(validate the incoming csrf_token for login/register before processing
authentication) and reject requests with missing/invalid tokens.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@public/login.html`:
- Around line 75-76: Add a for attribute to the password label to associate it
with the input by setting for="r-password" on the <label> that corresponds to
the input with id="r-password" (update the label element near the Password
field); also audit and add matching for="..." attributes for the other labels
referencing inputs with ids on this page (the labels near ids used at lines
corresponding to other inputs) to ensure proper accessibility and
keyboard/screen-reader association.

---

Outside diff comments:
In `@public/login.html`:
- Line 36: Add server-generated CSRF tokens to both forms (e.g., the form
element with id "form-login" and the register form) by rendering a hidden input
named "csrf_token" (and an id like "csrf-token") into public/login.html and the
corresponding register HTML; ensure client-side submit handlers include that
token in the fetch body or request header when sending the form; finally add
token verification in the server request handlers in worker.py (validate the
incoming csrf_token for login/register before processing authentication) and
reject requests with missing/invalid tokens.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 511d1142-a958-4d0d-91e9-c862e31bca5a

📥 Commits

Reviewing files that changed from the base of the PR and between d6e1a9c and 2906fca.

📒 Files selected for processing (1)
  • public/login.html

Comment on lines 75 to +76
<label class="block text-sm font-medium text-slate-700 mb-1">Password</label>
<input id="r-password" type="password" autocomplete="new-password" required minlength="6"
class="w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-brand/40 text-sm" placeholder="min 6 characters" />
<input id="r-password" type="password" autocomplete="new-password" required minlength="8"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add for attribute to label for proper accessibility.

The label on line 75 should include a for="r-password" attribute to explicitly associate it with the password input field. This is essential for screen readers and improves keyboard navigation.

♿ Proposed fix to add label association
-          <label class="block text-sm font-medium text-slate-700 mb-1">Password</label>
+          <label for="r-password" class="block text-sm font-medium text-slate-700 mb-1">Password</label>
           <input id="r-password" type="password" autocomplete="new-password" required minlength="8"

Note: This same issue exists for all other labels in the file (lines 38, 43, 60, 65, and 70). Consider updating them as well for comprehensive accessibility compliance.

As per coding guidelines: "Review HTML templates for accessibility (ARIA attributes, semantic elements)..."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<label class="block text-sm font-medium text-slate-700 mb-1">Password</label>
<input id="r-password" type="password" autocomplete="new-password" required minlength="6"
class="w-full px-4 py-2.5 rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-brand/40 text-sm" placeholder="min 6 characters" />
<input id="r-password" type="password" autocomplete="new-password" required minlength="8"
<label for="r-password" class="block text-sm font-medium text-slate-700 mb-1">Password</label>
<input id="r-password" type="password" autocomplete="new-password" required minlength="8"
🧰 Tools
🪛 HTMLHint (1.9.2)

[warning] 76-76: No matching [ label ] tag found.

(input-requires-label)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@public/login.html` around lines 75 - 76, Add a for attribute to the password
label to associate it with the input by setting for="r-password" on the <label>
that corresponds to the input with id="r-password" (update the label element
near the Password field); also audit and add matching for="..." attributes for
the other labels referencing inputs with ids on this page (the labels near ids
used at lines corresponding to other inputs) to ensure proper accessibility and
keyboard/screen-reader association.

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