🐛 Clearing errors between steps customer login
This commit is contained in:
parent
74f46f9766
commit
c8c30c05c5
@ -57,6 +57,7 @@ export default function Login() {
|
|||||||
setPartialPhoneNumber(res.partialPhoneNumber);
|
setPartialPhoneNumber(res.partialPhoneNumber);
|
||||||
setTotpCodeUid(res.totpCodeUid);
|
setTotpCodeUid(res.totpCodeUid);
|
||||||
setStep(LoginStep.TOTP);
|
setStep(LoginStep.TOTP);
|
||||||
|
setValidationErrors([]);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
setValidationErrors([
|
setValidationErrors([
|
||||||
{
|
{
|
||||||
@ -79,6 +80,7 @@ export default function Login() {
|
|||||||
// If the code is valid setting it in state
|
// If the code is valid setting it in state
|
||||||
if (res.validCode) setTotpCode(values["totpCode"]);
|
if (res.validCode) setTotpCode(values["totpCode"]);
|
||||||
|
|
||||||
|
setValidationErrors([]);
|
||||||
// If it's first connection, show the form for first connection
|
// If it's first connection, show the form for first connection
|
||||||
if (res.reason === TotpCodesReasons.FIRST_LOGIN) setStep(LoginStep.NEW_PASSWORD);
|
if (res.reason === TotpCodesReasons.FIRST_LOGIN) setStep(LoginStep.NEW_PASSWORD);
|
||||||
// If it's password forgotten, show the form for password forgotten
|
// 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"] });
|
const token = await Auth.getInstance().setPassword({ totpCode, email, password: values["password"] });
|
||||||
CustomerStore.instance.connect(token.accessToken, token.refreshToken);
|
CustomerStore.instance.connect(token.accessToken, token.refreshToken);
|
||||||
|
setValidationErrors([]);
|
||||||
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
||||||
// If set password worked, setting the token and redirecting
|
// If set password worked, setting the token and redirecting
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -153,6 +156,7 @@ export default function Login() {
|
|||||||
if (!values["password"]) return;
|
if (!values["password"]) return;
|
||||||
const token = await Auth.getInstance().login({ totpCode, email, password: values["password"] });
|
const token = await Auth.getInstance().login({ totpCode, email, password: values["password"] });
|
||||||
CustomerStore.instance.connect(token.accessToken, token.refreshToken);
|
CustomerStore.instance.connect(token.accessToken, token.refreshToken);
|
||||||
|
setValidationErrors([]);
|
||||||
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
router.push(Module.getInstance().get().modules.pages.Folder.pages.Select.props.path);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
setValidationErrors([
|
setValidationErrors([
|
||||||
@ -173,6 +177,7 @@ export default function Login() {
|
|||||||
try {
|
try {
|
||||||
const res = await Auth.getInstance().askNewPassword({ email });
|
const res = await Auth.getInstance().askNewPassword({ email });
|
||||||
setPartialPhoneNumber(res.partialPhoneNumber);
|
setPartialPhoneNumber(res.partialPhoneNumber);
|
||||||
|
setValidationErrors([]);
|
||||||
setStep(LoginStep.TOTP);
|
setStep(LoginStep.TOTP);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// If token already exists and is still valid redirect to the connect/register page
|
// If token already exists and is still valid redirect to the connect/register page
|
||||||
@ -188,6 +193,7 @@ export default function Login() {
|
|||||||
try {
|
try {
|
||||||
const res = await Auth.getInstance().sendAnotherCode({ email, totpCodeUid });
|
const res = await Auth.getInstance().sendAnotherCode({ email, totpCodeUid });
|
||||||
|
|
||||||
|
setValidationErrors([]);
|
||||||
setPartialPhoneNumber(res.partialPhoneNumber);
|
setPartialPhoneNumber(res.partialPhoneNumber);
|
||||||
setTotpCodeUid(res.totpCodeUid);
|
setTotpCodeUid(res.totpCodeUid);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user