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