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

SHARD-8982: limit password length #72

Merged
merged 3 commits into from
Dec 9, 2024
Merged
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
20 changes: 12 additions & 8 deletions components/molecules/PasswordResetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type FormData = {
function validPassword(password: string) {
return (
password.length >= 8 &&
password.length <= 128 &&
/[A-Z]/.test(password) &&
/[a-z]/.test(password) &&
/[0-9]/.test(password) &&
Expand Down Expand Up @@ -84,13 +85,11 @@ const PasswordResetForm = () => {
setError(
`newPassword`,
{
message:
"The password does not meet the requirements!",
message: "The password does not meet the requirements!",
},
{ shouldFocus: true }
);
}
else if (data.currentPassword == data.newPassword) {
} else if (data.currentPassword == data.newPassword) {
setError(
`newPassword`,
{ message: "New password is the same as the current password" },
Expand All @@ -105,7 +104,7 @@ const PasswordResetForm = () => {
} else {
await changePassword(data.currentPassword, data.newPassword);
resetForm();
setIsPasswordReset(true); // Show success alert
setIsPasswordReset(true); // Show success alert

// Hide the alert after 3 seconds
setTimeout(() => {
Expand All @@ -118,8 +117,10 @@ const PasswordResetForm = () => {
<div className="flex flex-col gap-y-2">
<span className="font-semibold">Password Reset</span>
<p className="text-sm text-gray-500">
Password requirements: min 8 characters, at least 1 lower case letter, at least 1 upper case letter, at least 1
number, at least 1 special character (<span className="text-sm text-gray-400">{"!@#$%^&*()_+*$"}</span>)
Password requirements: min 8 characters, at least 1 lower case letter,

Choose a reason for hiding this comment

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

we should also add max 128 char

at least 1 upper case letter, at least 1 number, at least 1 special
character (
<span className="text-sm text-gray-400">{"!@#$%^&*()_+*$"}</span>)
</p>
<Card>
<form
Expand All @@ -130,7 +131,10 @@ const PasswordResetForm = () => {
{isPasswordReset && (
<div className="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4">
<strong className="font-bold">Success!</strong>
<span className="block sm:inline"> Your password has been reset successfully.</span>
<span className="block sm:inline">
{" "}
Your password has been reset successfully.
</span>
</div>
)}

Expand Down
Loading