mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 08:23:16 +00:00
cleanup loading states
This commit is contained in:
@@ -61,11 +61,13 @@ export function ChangePasswordForm({
|
|||||||
const changeResponse = await setMyPassword({
|
const changeResponse = await setMyPassword({
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not change password");
|
.catch(() => {
|
||||||
});
|
setError("Could not change password");
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (changeResponse && "error" in changeResponse) {
|
if (changeResponse && "error" in changeResponse) {
|
||||||
setError(changeResponse.error);
|
setError(changeResponse.error);
|
||||||
@@ -86,13 +88,14 @@ export function ChangePasswordForm({
|
|||||||
password: { password: values.password },
|
password: { password: values.password },
|
||||||
}),
|
}),
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch(() => {
|
})
|
||||||
setLoading(false);
|
.catch(() => {
|
||||||
setError("Could not verify password");
|
setError("Could not verify password");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
passwordResponse &&
|
passwordResponse &&
|
||||||
|
|||||||
@@ -60,9 +60,10 @@ export function IdpSignin({
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(error.message);
|
setError(error.message);
|
||||||
return;
|
return;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -55,13 +55,14 @@ export function InviteForm({
|
|||||||
firstName: values.firstname,
|
firstName: values.firstname,
|
||||||
lastName: values.lastname,
|
lastName: values.lastname,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not create invitation Code");
|
.catch(() => {
|
||||||
setLoading(false);
|
setError("Could not create invitation Code");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (response && typeof response === "object" && "error" in response) {
|
if (response && typeof response === "object" && "error" in response) {
|
||||||
setError(response.error);
|
setError(response.error);
|
||||||
|
|||||||
@@ -57,11 +57,10 @@ export function LoginOTP({
|
|||||||
initialized.current = true;
|
initialized.current = true;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
updateSessionForOTPChallenge()
|
updateSessionForOTPChallenge()
|
||||||
.then((response) => {
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -89,12 +88,13 @@ export function LoginOTP({
|
|||||||
organization,
|
organization,
|
||||||
challenges,
|
challenges,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch((error) => {
|
})
|
||||||
setError(error.message ?? "Could not request OTP challenge");
|
.catch((error) => {
|
||||||
setLoading(false);
|
setError(error.message ?? "Could not request OTP challenge");
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -139,13 +139,14 @@ export function LoginOTP({
|
|||||||
organization,
|
organization,
|
||||||
checks,
|
checks,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not verify OTP code");
|
.catch(() => {
|
||||||
setLoading(false);
|
setError("Could not verify OTP code");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -206,11 +207,10 @@ export function LoginOTP({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
updateSessionForOTPChallenge()
|
updateSessionForOTPChallenge()
|
||||||
.then((response) => {
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -61,16 +61,17 @@ export function LoginPasskey({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return submitLoginAndContinue(pK)
|
return submitLoginAndContinue(pK)
|
||||||
.then(() => {
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -94,10 +95,13 @@ export function LoginPasskey({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not request passkey challenge");
|
.catch(() => {
|
||||||
});
|
setError("Could not request passkey challenge");
|
||||||
setLoading(false);
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
@@ -112,11 +116,13 @@ export function LoginPasskey({
|
|||||||
webAuthN: { credentialAssertionData: data },
|
webAuthN: { credentialAssertionData: data },
|
||||||
} as Checks,
|
} as Checks,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not verify passkey");
|
.catch(() => {
|
||||||
});
|
setError("Could not verify passkey");
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -243,7 +249,9 @@ export function LoginPasskey({
|
|||||||
variant={ButtonVariants.Primary}
|
variant={ButtonVariants.Primary}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const response = await updateSessionForChallenge();
|
const response = await updateSessionForChallenge().finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
const pK =
|
const pK =
|
||||||
response?.challenges?.webAuthN?.publicKeyCredentialRequestOptions
|
response?.challenges?.webAuthN?.publicKeyCredentialRequestOptions
|
||||||
@@ -251,15 +259,16 @@ export function LoginPasskey({
|
|||||||
|
|
||||||
if (!pK) {
|
if (!pK) {
|
||||||
setError("Could not request passkey challenge");
|
setError("Could not request passkey challenge");
|
||||||
setLoading(false);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
return submitLoginAndContinue(pK)
|
return submitLoginAndContinue(pK)
|
||||||
.then(() => {
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -60,13 +60,14 @@ export function PasswordForm({
|
|||||||
}),
|
}),
|
||||||
authRequestId,
|
authRequestId,
|
||||||
forceMfa: loginSettings?.forceMfa,
|
forceMfa: loginSettings?.forceMfa,
|
||||||
}).catch(() => {
|
})
|
||||||
setLoading(false);
|
.catch(() => {
|
||||||
setError("Could not verify password");
|
setError("Could not verify password");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (response && "error" in response && response.error) {
|
if (response && "error" in response && response.error) {
|
||||||
setError(response.error);
|
setError(response.error);
|
||||||
@@ -83,12 +84,14 @@ export function PasswordForm({
|
|||||||
const response = await resetPassword({
|
const response = await resetPassword({
|
||||||
loginName,
|
loginName,
|
||||||
organization,
|
organization,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not reset password");
|
.catch(() => {
|
||||||
return;
|
setError("Could not reset password");
|
||||||
});
|
return;
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (response && "error" in response) {
|
if (response && "error" in response) {
|
||||||
setError(response.error);
|
setError(response.error);
|
||||||
|
|||||||
@@ -50,11 +50,14 @@ export function RegisterPasskey({
|
|||||||
passkeyName,
|
passkeyName,
|
||||||
publicKeyCredential,
|
publicKeyCredential,
|
||||||
sessionId,
|
sessionId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not verify Passkey");
|
.catch(() => {
|
||||||
});
|
setError("Could not verify Passkey");
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +65,13 @@ export function RegisterPasskey({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const resp = await registerPasskeyLink({
|
const resp = await registerPasskeyLink({
|
||||||
sessionId,
|
sessionId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not register passkey");
|
.catch(() => {
|
||||||
});
|
setError("Could not register passkey");
|
||||||
setLoading(false);
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
setError("An error on registering passkey");
|
setError("An error on registering passkey");
|
||||||
|
|||||||
@@ -47,16 +47,18 @@ export function RegisterU2f({
|
|||||||
passkeyName,
|
passkeyName,
|
||||||
publicKeyCredential,
|
publicKeyCredential,
|
||||||
sessionId,
|
sessionId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("An error on verifying passkey occurred");
|
.catch(() => {
|
||||||
});
|
setError("An error on verifying passkey occurred");
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (response && "error" in response && response?.error) {
|
if (response && "error" in response && response?.error) {
|
||||||
setError(response?.error);
|
setError(response?.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +67,13 @@ export function RegisterU2f({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await addU2F({
|
const response = await addU2F({
|
||||||
sessionId,
|
sessionId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("An error on registering passkey");
|
.catch(() => {
|
||||||
});
|
setError("An error on registering passkey");
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (response && "error" in response && response?.error) {
|
if (response && "error" in response && response?.error) {
|
||||||
setError(response?.error);
|
setError(response?.error);
|
||||||
@@ -115,7 +119,6 @@ export function RegisterU2f({
|
|||||||
!(resp as any).rawId
|
!(resp as any).rawId
|
||||||
) {
|
) {
|
||||||
setError("An error on registering passkey");
|
setError("An error on registering passkey");
|
||||||
setLoading(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +142,6 @@ export function RegisterU2f({
|
|||||||
const submitResponse = await submitVerify(u2fId, "", data, sessionId);
|
const submitResponse = await submitVerify(u2fId, "", data, sessionId);
|
||||||
|
|
||||||
if (!submitResponse) {
|
if (!submitResponse) {
|
||||||
setLoading(false);
|
|
||||||
setError("An error on verifying passkey");
|
setError("An error on verifying passkey");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,8 +179,6 @@ export function RegisterU2f({
|
|||||||
|
|
||||||
router.push(urlToContinue);
|
router.push(urlToContinue);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -40,11 +40,14 @@ export function SessionItem({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
const response = await cleanupSession({
|
const response = await cleanupSession({
|
||||||
sessionId: id,
|
sessionId: id,
|
||||||
}).catch((error) => {
|
})
|
||||||
setError(error.message);
|
.catch((error) => {
|
||||||
});
|
setError(error.message);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,13 +71,14 @@ export function SetPasswordForm({
|
|||||||
payload = { ...payload, code: values.code };
|
payload = { ...payload, code: values.code };
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeResponse = await changePassword(payload).catch(() => {
|
const changeResponse = await changePassword(payload)
|
||||||
setError("Could not set password");
|
.catch(() => {
|
||||||
setLoading(false);
|
setError("Could not set password");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (changeResponse && "error" in changeResponse) {
|
if (changeResponse && "error" in changeResponse) {
|
||||||
setError(changeResponse.error);
|
setError(changeResponse.error);
|
||||||
@@ -107,13 +108,14 @@ export function SetPasswordForm({
|
|||||||
password: { password: values.password },
|
password: { password: values.password },
|
||||||
}),
|
}),
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch((error) => {
|
})
|
||||||
setLoading(false);
|
.catch(() => {
|
||||||
setError("Could not verify password");
|
setError("Could not verify password");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
passwordResponse &&
|
passwordResponse &&
|
||||||
|
|||||||
@@ -65,11 +65,13 @@ export function SetRegisterPasswordForm({
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
authRequestId: authRequestId,
|
authRequestId: authRequestId,
|
||||||
password: values.password,
|
password: values.password,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not register user");
|
.catch(() => {
|
||||||
});
|
setError("Could not register user");
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (response && "error" in response) {
|
if (response && "error" in response) {
|
||||||
setError(response.error);
|
setError(response.error);
|
||||||
|
|||||||
@@ -53,11 +53,13 @@ export function SignInWithIdp({
|
|||||||
`${host}/idp/${provider}/success?` + new URLSearchParams(params),
|
`${host}/idp/${provider}/success?` + new URLSearchParams(params),
|
||||||
failureUrl:
|
failureUrl:
|
||||||
`${host}/idp/${provider}/failure?` + new URLSearchParams(params),
|
`${host}/idp/${provider}/failure?` + new URLSearchParams(params),
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not start IDP flow");
|
.catch(() => {
|
||||||
});
|
setError("Could not start IDP flow");
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export function TotpRegister({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
return verifyTOTP(values.code, loginName, organization)
|
return verifyTOTP(values.code, loginName, organization)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setLoading(false);
|
|
||||||
// if attribute is set, validate MFA after it is setup, otherwise proceed as usual (when mfa is enforced to login)
|
// if attribute is set, validate MFA after it is setup, otherwise proceed as usual (when mfa is enforced to login)
|
||||||
if (checkAfter) {
|
if (checkAfter) {
|
||||||
const params = new URLSearchParams({});
|
const params = new URLSearchParams({});
|
||||||
@@ -96,8 +95,10 @@ export function TotpRegister({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
setLoading(false);
|
|
||||||
setError(e.message);
|
setError(e.message);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,11 +52,13 @@ export function UsernameForm({
|
|||||||
loginName: values.loginName,
|
loginName: values.loginName,
|
||||||
organization,
|
organization,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("An internal error occurred");
|
.catch(() => {
|
||||||
});
|
setError("An internal error occurred");
|
||||||
|
})
|
||||||
setLoading(false);
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
if (res?.error) {
|
if (res?.error) {
|
||||||
setError(res.error);
|
setError(res.error);
|
||||||
|
|||||||
@@ -41,13 +41,15 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
|||||||
const response = await resendVerification({
|
const response = await resendVerification({
|
||||||
userId,
|
userId,
|
||||||
isInvite: isInvite,
|
isInvite: isInvite,
|
||||||
}).catch(() => {
|
})
|
||||||
setError("Could not resend email");
|
.catch(() => {
|
||||||
setLoading(false);
|
setError("Could not resend email");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,13 +63,14 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
|||||||
code: value.code,
|
code: value.code,
|
||||||
userId,
|
userId,
|
||||||
isInvite: isInvite,
|
isInvite: isInvite,
|
||||||
}).catch((error) => {
|
})
|
||||||
setError("Could not verify user");
|
.catch(() => {
|
||||||
setLoading(false);
|
setError("Could not verify user");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[isInvite, userId],
|
[isInvite, userId],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,13 +29,14 @@ export function VerifyRedirectButton({
|
|||||||
await sendVerificationRedirectWithoutCheck({
|
await sendVerificationRedirectWithoutCheck({
|
||||||
userId,
|
userId,
|
||||||
authRequestId,
|
authRequestId,
|
||||||
}).catch((error) => {
|
})
|
||||||
setError("Could not verify user");
|
.catch((error) => {
|
||||||
setLoading(false);
|
setError("Could not verify user");
|
||||||
return;
|
return;
|
||||||
});
|
})
|
||||||
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user