mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-15 18:02:13 +00:00
redirect from server action
This commit is contained in:
@@ -58,6 +58,7 @@ export function InviteForm({
|
||||
}).catch(() => {
|
||||
setError("Could not create invitation Code");
|
||||
setLoading(false);
|
||||
return;
|
||||
});
|
||||
|
||||
setLoading(false);
|
||||
@@ -69,6 +70,7 @@ export function InviteForm({
|
||||
|
||||
if (!response) {
|
||||
setError("Could not create invitation Code");
|
||||
return;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({});
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
verifyUserAndCreateSession,
|
||||
} from "@/lib/server/email";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/router";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Button, ButtonVariants } from "./button";
|
||||
@@ -65,6 +65,7 @@ export function VerifyForm({ userId, code, isInvite, params }: Props) {
|
||||
userId,
|
||||
isInvite: isInvite,
|
||||
}).catch(() => {
|
||||
console.log(error);
|
||||
setError("Could not verify email");
|
||||
setLoading(false);
|
||||
return;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import {
|
||||
getUserByID,
|
||||
listAuthenticationMethodTypes,
|
||||
resendEmailCode,
|
||||
resendInviteCode,
|
||||
verifyEmail,
|
||||
@@ -9,6 +10,7 @@ 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 = {
|
||||
@@ -54,10 +56,37 @@ export async function verifyUserAndCreateSession(
|
||||
command.authRequestId,
|
||||
);
|
||||
|
||||
return {
|
||||
sessionId: session.id,
|
||||
factors: session.factors,
|
||||
};
|
||||
const authMethodResponse = await listAuthenticationMethodTypes(
|
||||
command.userId,
|
||||
);
|
||||
|
||||
if (!authMethodResponse || !authMethodResponse.authMethodTypes) {
|
||||
return { error: "Could not load possible authenticators" };
|
||||
}
|
||||
console.log("xs");
|
||||
// if no authmethods are found on the user, redirect to set one up
|
||||
if (
|
||||
authMethodResponse &&
|
||||
authMethodResponse.authMethodTypes &&
|
||||
authMethodResponse.authMethodTypes.length == 0
|
||||
) {
|
||||
const params = new URLSearchParams({
|
||||
sessionId: session.id,
|
||||
});
|
||||
|
||||
if (session.factors?.user?.loginName) {
|
||||
params.set("loginName", session.factors?.user?.loginName);
|
||||
}
|
||||
|
||||
console.log("/authenticator/set?" + params);
|
||||
return redirect("/authenticator/set?" + params);
|
||||
}
|
||||
|
||||
// return {
|
||||
// authMethodTypes: authMethodResponse.authMethodTypes,
|
||||
// sessionId: session.id,
|
||||
// factors: session.factors,
|
||||
// };
|
||||
}
|
||||
|
||||
type resendVerifyEmailCommand = {
|
||||
|
||||
Reference in New Issue
Block a user