-
Notifications
You must be signed in to change notification settings - Fork 114
fix: Password requirement are not clear on the email signup page #3771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ export const Login: React.FC = () => { | |
| const [signupEmail, setSignupEmail] = useState(""); | ||
| const [signupPassword, setSignupPassword] = useState(""); | ||
| const [signupConfirmPassword, setSignupConfirmPassword] = useState(""); | ||
| const [signupFieldErrors, setSignupFieldErrors] = useState<Record<string, string>>({}); | ||
|
|
||
| const [magicCodeStep, setMagicCodeStep] = useState<MagicCodeStep>("email"); | ||
| const [magicCodeEmail, setMagicCodeEmail] = useState(""); | ||
|
|
@@ -359,6 +360,13 @@ export const Login: React.FC = () => { | |
| } | ||
| }; | ||
|
|
||
| const isPasswordValid = (password: string) => { | ||
| if (password.length < 8) return false; | ||
| if (!/[0-9]/.test(password)) return false; | ||
| if (!/[A-Z]/.test(password)) return false; | ||
| return true; | ||
| }; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated
|
||
|
|
||
| const handleSignupSubmit = async (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| setFormError(null); | ||
|
|
@@ -368,6 +376,8 @@ export const Login: React.FC = () => { | |
| return; | ||
| } | ||
|
|
||
| const fieldErrors: Record<string, string> = {}; | ||
|
|
||
| if (!signupFirstName.trim() || !signupLastName.trim()) { | ||
| setFormError("First and last names are required"); | ||
| return; | ||
|
|
@@ -378,8 +388,16 @@ export const Login: React.FC = () => { | |
| return; | ||
| } | ||
|
|
||
| if (!isPasswordValid(signupPassword)) { | ||
| fieldErrors.password = "Password must be 8+ characters with at least 1 number and 1 capital letter."; | ||
| } | ||
|
|
||
| if (signupPassword !== signupConfirmPassword) { | ||
| setFormError("Passwords do not match"); | ||
| fieldErrors.confirmPassword = "Passwords do not match."; | ||
| } | ||
|
|
||
| setSignupFieldErrors(fieldErrors); | ||
| if (Object.keys(fieldErrors).length > 0) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stale field errors persist after early returnMedium Severity
|
||
| return; | ||
| } | ||
|
|
||
|
|
@@ -609,6 +627,11 @@ export const Login: React.FC = () => { | |
| value={signupPassword} | ||
| onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSignupPassword(e.target.value)} | ||
| /> | ||
| {signupFieldErrors.password ? ( | ||
| <p className="text-xs text-red-600">{signupFieldErrors.password}</p> | ||
| ) : ( | ||
| <p className="text-xs text-gray-500">8+ characters, at least 1 number and 1 capital letter</p> | ||
| )} | ||
| </div> | ||
|
|
||
| <div className="space-y-2"> | ||
|
|
@@ -622,6 +645,9 @@ export const Login: React.FC = () => { | |
| value={signupConfirmPassword} | ||
| onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSignupConfirmPassword(e.target.value)} | ||
| /> | ||
| {signupFieldErrors.confirmPassword && ( | ||
| <p className="text-xs text-red-600">{signupFieldErrors.confirmPassword}</p> | ||
| )} | ||
| </div> | ||
|
|
||
| <LoadingButton | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field errors not cleared when toggling modes
Low Severity
The newly introduced
signupFieldErrorsstate is not cleared inhandleToggleMode(which clearsformErrorbut notsignupFieldErrors). If a user triggers password field errors, switches to login mode, and then switches back to signup mode, the stale red error text remains visible on the password field instead of reverting to the hint.