mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-13 16:22:12 +00:00
redirect from server
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { registerUser, RegisterUserResponse } from "@/lib/server/register";
|
||||
import { registerUser } from "@/lib/server/register";
|
||||
import { LegalAndSupportSettings } from "@zitadel/proto/zitadel/settings/v2/legal_settings_pb";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -66,6 +66,7 @@ export function RegisterFormWithoutPassword({
|
||||
firstName: values.firstname,
|
||||
lastName: values.lastname,
|
||||
organization: organization,
|
||||
authRequestId: authRequestId,
|
||||
}).catch((error) => {
|
||||
setError("Could not register user");
|
||||
setLoading(false);
|
||||
@@ -98,22 +99,7 @@ export function RegisterFormWithoutPassword({
|
||||
if (withPassword) {
|
||||
return router.push(`/register?` + new URLSearchParams(registerParams));
|
||||
} else {
|
||||
const session = (await submitAndRegister(value)) as RegisterUserResponse;
|
||||
|
||||
const params = new URLSearchParams({});
|
||||
if (session?.factors?.user?.loginName) {
|
||||
params.set("loginName", session.factors?.user?.loginName);
|
||||
}
|
||||
|
||||
if (organization) {
|
||||
params.set("organization", organization);
|
||||
}
|
||||
|
||||
if (authRequestId) {
|
||||
params.set("authRequestId", authRequestId);
|
||||
}
|
||||
|
||||
return router.push(`/passkey/set?` + new URLSearchParams(params));
|
||||
return submitAndRegister(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ChecksJson,
|
||||
ChecksSchema,
|
||||
} from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
type RegisterUserCommand = {
|
||||
email: string;
|
||||
@@ -23,7 +24,6 @@ export type RegisterUserResponse = {
|
||||
sessionId: string;
|
||||
factors: Factors | undefined;
|
||||
};
|
||||
|
||||
export async function registerUser(command: RegisterUserCommand) {
|
||||
const human = await addHumanUser({
|
||||
email: command.email,
|
||||
@@ -50,7 +50,7 @@ export async function registerUser(command: RegisterUserCommand) {
|
||||
|
||||
const checks = create(ChecksSchema, checkPayload);
|
||||
|
||||
return createSessionAndUpdateCookie(
|
||||
const session = await createSessionAndUpdateCookie(
|
||||
checks,
|
||||
undefined,
|
||||
command.authRequestId,
|
||||
@@ -61,4 +61,19 @@ export async function registerUser(command: RegisterUserCommand) {
|
||||
factors: session.factors,
|
||||
};
|
||||
});
|
||||
|
||||
if (!session || !session.factors?.user) {
|
||||
return { error: "Could not create session" };
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({
|
||||
loginName: session.factors.user.loginName,
|
||||
organization: session.factors.user.organizationId,
|
||||
});
|
||||
|
||||
if (command.authRequestId) {
|
||||
params.append("authRequestId", command.authRequestId);
|
||||
}
|
||||
|
||||
return redirect("/passkey/set?" + params);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user