From c8c30c05c57a0582aaaf18c87ea0b42d22d8920c Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Mon, 18 Dec 2023 11:02:21 +0100 Subject: [PATCH] :bug: Clearing errors between steps customer login --- src/front/Components/Layouts/LoginCustomer/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/front/Components/Layouts/LoginCustomer/index.tsx b/src/front/Components/Layouts/LoginCustomer/index.tsx index 8dbc3736..78c8af2e 100644 --- a/src/front/Components/Layouts/LoginCustomer/index.tsx +++ b/src/front/Components/Layouts/LoginCustomer/index.tsx @@ -57,6 +57,7 @@ export default function Login() { setPartialPhoneNumber(res.partialPhoneNumber); setTotpCodeUid(res.totpCodeUid); setStep(LoginStep.TOTP); + setValidationErrors([]); } catch (error: any) { setValidationErrors([ { @@ -79,6 +80,7 @@ export default function Login() { // If the code is valid setting it in state if (res.validCode) setTotpCode(values["totpCode"]); + setValidationErrors([]); // If it's first connection, show the form for first connection if (res.reason === TotpCodesReasons.FIRST_LOGIN) setStep(LoginStep.NEW_PASSWORD); // If it's password forgotten, show the form for password forgotten @@ -130,6 +132,7 @@ export default function Login() { } const token = await Auth.getInstance().setPassword({ totpCode, email, password: values["password"] }); CustomerStore.instance.connect(token.accessToken, token.refreshToken); + setValidationErrors([]); router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path); // If set password worked, setting the token and redirecting } catch (error: any) { @@ -153,6 +156,7 @@ export default function Login() { if (!values["password"]) return; const token = await Auth.getInstance().login({ totpCode, email, password: values["password"] }); CustomerStore.instance.connect(token.accessToken, token.refreshToken); + setValidationErrors([]); router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path); } catch (error: any) { setValidationErrors([ @@ -173,6 +177,7 @@ export default function Login() { try { const res = await Auth.getInstance().askNewPassword({ email }); setPartialPhoneNumber(res.partialPhoneNumber); + setValidationErrors([]); setStep(LoginStep.TOTP); } catch (error: any) { // If token already exists and is still valid redirect to the connect/register page @@ -188,6 +193,7 @@ export default function Login() { try { const res = await Auth.getInstance().sendAnotherCode({ email, totpCodeUid }); + setValidationErrors([]); setPartialPhoneNumber(res.partialPhoneNumber); setTotpCodeUid(res.totpCodeUid); } catch (error: any) {