push instead of redirect

This commit is contained in:
Max Peintner
2024-12-09 11:44:12 +01:00
parent 2bc7629cca
commit 40e51e11fe
2 changed files with 6 additions and 3 deletions

View File

@@ -65,10 +65,14 @@ export function SessionItem({
<button <button
onClick={async () => { onClick={async () => {
if (valid && session?.factors?.user) { if (valid && session?.factors?.user) {
return continueWithSession({ const resp = await continueWithSession({
...session, ...session,
authRequestId: authRequestId, authRequestId: authRequestId,
}); });
if (resp?.redirect) {
return router.push(resp.redirect);
}
} else if (session.factors?.user) { } else if (session.factors?.user) {
setLoading(true); setLoading(true);
const res = await sendLoginname({ const res = await sendLoginname({

View File

@@ -15,7 +15,6 @@ import { RequestChallenges } from "@zitadel/proto/zitadel/session/v2/challenge_p
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb"; import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
import { Checks } from "@zitadel/proto/zitadel/session/v2/session_service_pb"; import { Checks } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
import { headers } from "next/headers"; import { headers } from "next/headers";
import { redirect } from "next/navigation";
import { getNextUrl } from "../client"; import { getNextUrl } from "../client";
import { import {
getMostRecentSessionCookie, getMostRecentSessionCookie,
@@ -108,7 +107,7 @@ export async function continueWithSession({
) )
: null; : null;
if (url) { if (url) {
return redirect(url); return { redirect: url };
} }
} }