mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 15:03:52 +00:00
parse orgId from authrequest scope
This commit is contained in:
@@ -16,6 +16,8 @@ async function loadSessions(ids: string[]): Promise<Session[]> {
|
||||
return response?.sessions ?? [];
|
||||
}
|
||||
|
||||
const ORG_SCOPE_REGEX = /urn:zitadel:iam:org:id:([0-9]*)/g;
|
||||
|
||||
function findSession(
|
||||
sessions: Session[],
|
||||
authRequest: AuthRequest
|
||||
@@ -87,6 +89,18 @@ export async function GET(request: NextRequest) {
|
||||
registerUrl.searchParams.set("authRequestId", authRequest?.id);
|
||||
}
|
||||
|
||||
if (
|
||||
authRequest.scope &&
|
||||
authRequest.scope.find((s) => ORG_SCOPE_REGEX.test(s))
|
||||
) {
|
||||
const orgId = authRequest.scope
|
||||
.find((s) => ORG_SCOPE_REGEX.test(s))
|
||||
?.match(ORG_SCOPE_REGEX)?.[1];
|
||||
console.log(orgId);
|
||||
if (orgId) {
|
||||
registerUrl.searchParams.set("orgId", orgId);
|
||||
}
|
||||
}
|
||||
return NextResponse.redirect(registerUrl);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from "react";
|
||||
import { getBrandingSettings, server } from "#/lib/zitadel";
|
||||
import { Logo } from "#/ui/Logo";
|
||||
|
||||
export default async function Layout({
|
||||
export default async function Template({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
Reference in New Issue
Block a user