Signup: enforce a minimum password length.

master
Tom Hacohen 4 years ago
parent 27209c282f
commit e738622396

@ -35,6 +35,8 @@ interface FormErrors {
errorGeneral?: string; errorGeneral?: string;
} }
const PASSWORD_MIN_LENGTH = 8;
export default function SignupPage() { export default function SignupPage() {
const credentials = useCredentials(); const credentials = useCredentials();
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -66,6 +68,8 @@ export default function SignupPage() {
} }
if (!password) { if (!password) {
errors.errorPassword = fieldRequired; errors.errorPassword = fieldRequired;
} else if (password.length < PASSWORD_MIN_LENGTH) {
errors.errorPassword = `Passwourds should be at least ${PASSWORD_MIN_LENGTH} digits long.`;
} }
if (process.env.NODE_ENV !== "development") { if (process.env.NODE_ENV !== "development") {
@ -197,6 +201,7 @@ export default function SignupPage() {
helperText={errors.errorPassword} helperText={errors.errorPassword}
label="Password" label="Password"
name="password" name="password"
inputProps={{ minLength: PASSWORD_MIN_LENGTH }}
value={password} value={password}
onChange={handleInputChange(setPassword)} onChange={handleInputChange(setPassword)}
/> />

Loading…
Cancel
Save