Description
The frontend signup form in src/pages/Signup/Signup.tsx applies a username validation regex that only permits letters and spaces:
if (!/^[A-Za-z\s]+$/.test(value)) {
errorMessage = "Only letters are allowed";
}
However, the backend validator in backend/validators/authValidator.js accepts usernames containing letters, numbers, and underscores:
username: z.string()
.regex(/^[a-zA-Z0-9_]+$/, "Username can only contain letters, numbers, and underscores")
These two rulesets directly contradict each other.
Impact
A user entering a username such as john_doe or john123 is blocked by the frontend with the message "Only letters are allowed", even though the backend would accept it. Users with common username patterns cannot register at all. The frontend also accepts spaces (e.g. john doe) that the backend rejects, producing a confusing server-side validation error after submission.
Steps to Reproduce
- Navigate to the Sign Up page.
- Enter a username containing a digit or underscore, e.g.
dev_user1.
- Observe the inline error: "Only letters are allowed".
- The form cannot be submitted despite the username being valid per the backend rules.
Expected Behavior
The frontend should permit the same character set as the backend: letters, digits, and underscores, with a consistent error message.
Proposed Fix
Update the username validation regex in src/pages/Signup/Signup.tsx to match the backend rule:
// Before
if (!/^[A-Za-z\s]+$/.test(value)) {
errorMessage = "Only letters are allowed";
}
// After
if (!/^[a-zA-Z0-9_]+$/.test(value)) {
errorMessage = "Username can only contain letters, numbers, and underscores";
}
Apply the same correction in the handleSubmit validation block in the same file.
Affected Files
src/pages/Signup/Signup.tsx
backend/validators/authValidator.js (source of truth for the accepted format)
Suggested Labels
type:bug level:intermediate quality:exceptional
I would like to work on this issue under GSSoC 2026. Could you please assign it to me? @GitMetricsLab
/assign
Description
The frontend signup form in
src/pages/Signup/Signup.tsxapplies a username validation regex that only permits letters and spaces:However, the backend validator in
backend/validators/authValidator.jsaccepts usernames containing letters, numbers, and underscores:These two rulesets directly contradict each other.
Impact
A user entering a username such as
john_doeorjohn123is blocked by the frontend with the message "Only letters are allowed", even though the backend would accept it. Users with common username patterns cannot register at all. The frontend also accepts spaces (e.g.john doe) that the backend rejects, producing a confusing server-side validation error after submission.Steps to Reproduce
dev_user1.Expected Behavior
The frontend should permit the same character set as the backend: letters, digits, and underscores, with a consistent error message.
Proposed Fix
Update the username validation regex in
src/pages/Signup/Signup.tsxto match the backend rule:Apply the same correction in the
handleSubmitvalidation block in the same file.Affected Files
src/pages/Signup/Signup.tsxbackend/validators/authValidator.js(source of truth for the accepted format)Suggested Labels
type:buglevel:intermediatequality:exceptionalI would like to work on this issue under GSSoC 2026. Could you please assign it to me? @GitMetricsLab
/assign