Added check that password is not an email address

This commit is contained in:
Joel Biddle
2023-08-23 02:14:22 +10:00
parent 2960f86647
commit ea262da505
15 changed files with 88 additions and 13 deletions
+21 -4
View File
@@ -35,6 +35,7 @@ export default function PasswordReset() {
const [passwordErrorNumber, setPasswordErrorNumber] = useState(false);
const [passwordErrorSpecialChar, setPasswordErrorSpecialChar] = useState(false);
const [passwordErrorRepeatedChar, setPasswordErrorRepeatedChar] = useState(false);
const [passwordErrorIsEmail, setPasswordErrorIsEmail] = useState(false);
const [passwordErrorIsBreachedPassword, setPasswordErrorIsBreachedPassword] = useState(false);
const router = useRouter();
@@ -79,6 +80,7 @@ export default function PasswordReset() {
setPasswordErrorNumber,
setPasswordErrorSpecialChar,
setPasswordErrorRepeatedChar,
setPasswordErrorIsEmail,
setPasswordErrorIsBreachedPassword,
errorCheck: false
});
@@ -240,6 +242,7 @@ export default function PasswordReset() {
setPasswordErrorNumber,
setPasswordErrorSpecialChar,
setPasswordErrorRepeatedChar,
setPasswordErrorIsEmail,
setPasswordErrorIsBreachedPassword,
errorCheck: false
});
@@ -255,6 +258,7 @@ export default function PasswordReset() {
passwordErrorNumber &&
passwordErrorSpecialChar &&
passwordErrorRepeatedChar &&
passwordErrorIsEmail &&
passwordErrorIsBreachedPassword
}
autoComplete="new-password"
@@ -268,6 +272,7 @@ export default function PasswordReset() {
passwordErrorNumber ||
passwordErrorSpecialChar ||
passwordErrorRepeatedChar ||
passwordErrorIsEmail ||
passwordErrorIsBreachedPassword ? (
<div className="mx-2 mt-3 mb-2 flex w-full max-w-md flex-col items-start rounded-md bg-white/5 px-2 py-2">
<div className="mb-1 text-sm text-gray-400">Password should contain:</div>
@@ -335,7 +340,7 @@ export default function PasswordReset() {
passwordErrorSpecialChar ? "text-gray-400" : "text-gray-600"
} text-sm`}
>
at least 1 special character
at least 1 special character (emojis and many langauge scripts supported)
</div>
</div>
<div className="ml-1 flex flex-row items-center justify-start">
@@ -349,7 +354,19 @@ export default function PasswordReset() {
passwordErrorRepeatedChar ? "text-gray-400" : "text-gray-600"
} text-sm`}
>
at most 2 repeated characters
at most 2 repeated, consecutive characters
</div>
</div>
<div className="ml-1 flex flex-row items-center justify-start">
{passwordErrorIsEmail ? (
<FontAwesomeIcon icon={faX} className="text-md mr-2.5 text-red" />
) : (
<FontAwesomeIcon icon={faCheck} className="text-md mr-2 text-primary" />
)}
<div
className={`${passwordErrorIsEmail ? "text-gray-400" : "text-gray-600"} text-sm`}
>
The password cannot be an email address.
</div>
</div>
<div className="ml-1 flex flex-row items-center justify-start">
@@ -363,8 +380,8 @@ export default function PasswordReset() {
passwordErrorIsBreachedPassword ? "text-gray-400" : "text-gray-600"
} text-sm`}
>
The password you provided is in a list of passwords commonly used on other websites.
Please try again with a stronger password.
The new password is in a list of passwords commonly used on other websites. Please
try again with a stronger password.
</div>
</div>
</div>
+1
View File
@@ -35,6 +35,7 @@ type Errors = {
number?: string;
specialChar?: string;
repeatedChar?: string;
isEmail?: string;
breachedPassword?: string;
};