Skip to content
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

password field bugs #1718

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const resetPasswordFormValidationSchema = Yup.object().shape({
password: Yup.string()
.matches(/^\S.*\S$/, "Password cannot start or end with a blank space")
.matches(
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s\x00-\x1F\x7F])[\S\s]{8,}$/, // eslint-disable-line
/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[_\W\s\x00-\x1F\x7F])[\S\s]{8,}$/, // eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

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

@Shruti-Apte Can you please confirm whether whitespace characters are allowed in passwords or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, whitespace was allowed before, Updated the code.

"Must Contain at least 8 Characters, One Uppercase, One Lowercase, One Number and One Special Character"
)
.required("Password cannot be blank"),
Expand Down
28 changes: 9 additions & 19 deletions app/javascript/src/components/Authentication/SignUp/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ const SignUpForm = () => {
setFieldError={setFieldError}
setFieldValue={setFieldValue}
type="password"
wrapperClassName="mb-6"
wrapperClassName={`${!errors.password && "mb-6"}`}
/>
<InputErrors
fieldErrors={errors.password}
fieldTouched={touched.password}
/>
</div>
<div className="field">
Expand All @@ -210,24 +214,10 @@ const SignUpForm = () => {
and 1 special character
</p>
)}
{errors.confirm_password == errors.password &&
(touched.password || touched.confirm_password) ? (
<InputErrors
fieldErrors={errors.confirm_password}
fieldTouched={
touched.confirm_password || touched.password
}
/>
) : (
(errors.confirm_password || errors.password) && (
<InputErrors
fieldErrors="Passwords must match"
fieldTouched={
touched.confirm_password || touched.password
}
/>
)
)}
<InputErrors
fieldErrors={errors.confirm_password}
fieldTouched={touched.confirm_password}
/>
</div>
<div className="my-6 flex text-xs font-normal leading-4 text-miru-dark-purple-1000">
<div className="mt-2 flex">
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/src/components/Authentication/SignUp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ export const signUpFormValidationSchema = Yup.object().shape({
password: Yup.string()
.matches(/^\S.*\S$/, "Password cannot start or end with a blank space")
.matches(
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s\x00-\x1F\x7F])[\S\s]{8,}$/, // eslint-disable-line
/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[_\W\s\x00-\x1F\x7F])[\S\s]{8,}$/, // eslint-disable-line
"Must Contain at least 8 Characters, One Uppercase, One Lowercase, One Number and One Special Character"
)
.required("Password cannot be blank"),
confirm_password: Yup.string()
.matches(/^\S.*\S$/, "Password cannot start or end with a blank space")
.matches(
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s\x00-\x1F\x7F])[\S\s]{8,}$/, // eslint-disable-line
/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[_\W\s\x00-\x1F\x7F])[\S\s]{8,}$/, // eslint-disable-line
"Must Contain at least 8 Characters, One Uppercase, One Lowercase, One Number and One Special Character"
)
.oneOf([Yup.ref("password"), null], "Passwords must match")
.required("Password cannot be blank"),
.required("Confirm Password cannot be blank"),
isAgreedTermsOfServices: Yup.boolean().oneOf(
[true],
"Please agree to the terms and privacy policy to continue"
Expand Down
Loading