mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 14:54:33 +00:00
return after error response
This commit is contained in:
@@ -64,6 +64,7 @@ export function ChangePasswordForm({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not change password");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -63,6 +63,7 @@ export function LoginOTP({
|
||||
updateSessionForOTPChallenge()
|
||||
.catch((error) => {
|
||||
setError(error);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -95,6 +96,7 @@ export function LoginOTP({
|
||||
})
|
||||
.catch((error) => {
|
||||
setError(error.message ?? "Could not request OTP challenge");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -202,6 +204,7 @@ export function LoginOTP({
|
||||
updateSessionForOTPChallenge()
|
||||
.catch((error) => {
|
||||
setError(error);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -67,6 +67,7 @@ export function LoginPasskey({
|
||||
return submitLoginAndContinue(pK)
|
||||
.catch((error) => {
|
||||
setError(error);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -74,6 +75,7 @@ export function LoginPasskey({
|
||||
})
|
||||
.catch((error) => {
|
||||
setError(error);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -102,6 +104,7 @@ export function LoginPasskey({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not request passkey challenge");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -123,6 +126,7 @@ export function LoginPasskey({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not verify passkey");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -151,7 +155,6 @@ export function LoginPasskey({
|
||||
})
|
||||
.then((assertedCredential: any) => {
|
||||
if (!assertedCredential) {
|
||||
setLoading(false);
|
||||
setError("An error on retrieving passkey");
|
||||
return;
|
||||
}
|
||||
@@ -204,6 +207,9 @@ export function LoginPasskey({
|
||||
router.push(url);
|
||||
}
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -275,6 +281,7 @@ export function LoginPasskey({
|
||||
return submitLoginAndContinue(pK)
|
||||
.catch((error) => {
|
||||
setError(error);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -53,6 +53,7 @@ export function RegisterPasskey({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not verify Passkey");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -68,6 +69,7 @@ export function RegisterPasskey({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not register passkey");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -54,6 +54,7 @@ export function RegisterU2f({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("An error on verifying passkey occurred");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -61,6 +62,7 @@ export function RegisterU2f({
|
||||
|
||||
if (response && "error" in response && response?.error) {
|
||||
setError(response?.error);
|
||||
return;
|
||||
}
|
||||
|
||||
return response;
|
||||
@@ -74,6 +76,7 @@ export function RegisterU2f({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("An error on registering passkey");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -81,6 +84,7 @@ export function RegisterU2f({
|
||||
|
||||
if (response && "error" in response && response?.error) {
|
||||
setError(response?.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response || !("u2fId" in response)) {
|
||||
|
||||
@@ -44,6 +44,7 @@ export function SessionItem({
|
||||
})
|
||||
.catch((error) => {
|
||||
setError(error.message);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -73,6 +74,7 @@ export function SessionItem({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("An internal error occurred");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -84,6 +86,7 @@ export function SessionItem({
|
||||
|
||||
if (res?.error) {
|
||||
setError(res.error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -68,6 +68,7 @@ export function SetRegisterPasswordForm({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not register user");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -56,6 +56,7 @@ export function SignInWithIdp({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("Could not start IDP flow");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -98,6 +98,7 @@ export function TotpRegister({
|
||||
})
|
||||
.catch((e) => {
|
||||
setError(e.message);
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -55,6 +55,7 @@ export function UsernameForm({
|
||||
})
|
||||
.catch(() => {
|
||||
setError("An internal error occurred");
|
||||
return;
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@@ -66,6 +67,7 @@ export function UsernameForm({
|
||||
|
||||
if (res?.error) {
|
||||
setError(res.error);
|
||||
return;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { Alert } from "@/components/alert";
|
||||
import { resendVerification, sendVerification } from "@/lib/server/email";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { redirect } from "next/navigation";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Button, ButtonVariants } from "./button";
|
||||
@@ -59,7 +60,7 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
||||
): Promise<boolean | void> {
|
||||
setLoading(true);
|
||||
|
||||
await sendVerification({
|
||||
const response = await sendVerification({
|
||||
code: value.code,
|
||||
userId,
|
||||
isInvite: isInvite,
|
||||
@@ -71,6 +72,15 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
if (response?.error) {
|
||||
setError(response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response?.redirect) {
|
||||
redirect(response?.redirect);
|
||||
}
|
||||
},
|
||||
[isInvite, userId],
|
||||
);
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
} from "@/lib/zitadel";
|
||||
import { create } from "@zitadel/client";
|
||||
import { ChecksSchema } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { redirect } from "next/navigation";
|
||||
import { createSessionAndUpdateCookie } from "./cookie";
|
||||
|
||||
type VerifyUserByEmailCommand = {
|
||||
@@ -74,7 +73,7 @@ export async function sendVerification(command: VerifyUserByEmailCommand) {
|
||||
if (session.factors?.user?.loginName) {
|
||||
params.set("loginName", session.factors?.user?.loginName);
|
||||
}
|
||||
return redirect(`/authenticator/set?${params}`);
|
||||
return { redirect: `/authenticator/set?${params}` };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +133,6 @@ export async function sendVerificationRedirectWithoutCheck(command: {
|
||||
if (session.factors?.user?.loginName) {
|
||||
params.set("loginName", session.factors?.user?.loginName);
|
||||
}
|
||||
return redirect(`/authenticator/set?${params}`);
|
||||
return { redirect: `/authenticator/set?${params}` };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user