feat: fixes
This commit is contained in:
@@ -6,7 +6,10 @@ import { background } from "../assets";
|
||||
import GradientButton from "../components/GradientButton";
|
||||
import { Input } from "../components/Input";
|
||||
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
||||
import { handleFirebaseError } from "../actions/signupActions";
|
||||
import {
|
||||
checkIfPasswordIsStrongEnough,
|
||||
handleFirebaseError,
|
||||
} from "../actions/signupActions";
|
||||
import firebase, { usersRef } from "../config/firebase";
|
||||
import Page from "../layouts/Page";
|
||||
import { isWeb } from "../hooks/useLayoutType";
|
||||
@@ -28,7 +31,7 @@ const CreatePassword = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [, setTooltip] = useGlobal("_tooltip");
|
||||
|
||||
const passwordRegex = useMemo(() => /^.{6,}$/, []);
|
||||
|
||||
|
||||
const handlePasswordChange = (text) => {
|
||||
setPassword(text);
|
||||
@@ -37,20 +40,22 @@ const CreatePassword = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!passwordRegex.test(text)) {
|
||||
setPasswordError("Ton mot de passe doit contenir au moins 6 caractères.");
|
||||
if (!checkIfPasswordIsStrongEnough({ password: text })) {
|
||||
setPasswordError(
|
||||
"Le mot de passe doit contenir au moins une majuscule, une minuscule, un chiffre et avoir une longueur minimale de 6 caractères",
|
||||
);
|
||||
} else {
|
||||
setPasswordError("");
|
||||
}
|
||||
};
|
||||
|
||||
const isPasswordValid = passwordRegex.test(password);
|
||||
const isPasswordValid = checkIfPasswordIsStrongEnough({ password });
|
||||
|
||||
const onCreateAccount = async () => {
|
||||
try {
|
||||
if (!isPasswordValid) {
|
||||
setTooltip({
|
||||
text: "Ton mot de passe doit contenir au moins 6 caractères.",
|
||||
text: "Le mot de passe doit contenir au moins une majuscule, une minuscule, un chiffre et avoir une longueur minimale de 6 caractères",
|
||||
type: "error",
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user