mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-18 20:40:57 +00:00
load default org on loginname
This commit is contained in:
@@ -3,11 +3,12 @@ import { SignInWithIdp } from "@/components/sign-in-with-idp";
|
|||||||
import { UsernameForm } from "@/components/username-form";
|
import { UsernameForm } from "@/components/username-form";
|
||||||
import {
|
import {
|
||||||
getBrandingSettings,
|
getBrandingSettings,
|
||||||
getLegalAndSupportSettings,
|
getDefaultOrg,
|
||||||
getLoginSettings,
|
getLoginSettings,
|
||||||
settingsService,
|
settingsService,
|
||||||
} from "@/lib/zitadel";
|
} from "@/lib/zitadel";
|
||||||
import { makeReqCtx } from "@zitadel/client/v2";
|
import { makeReqCtx } from "@zitadel/client/v2";
|
||||||
|
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
|
||||||
import { getLocale, getTranslations } from "next-intl/server";
|
import { getLocale, getTranslations } from "next-intl/server";
|
||||||
|
|
||||||
function getIdentityProviders(orgId?: string) {
|
function getIdentityProviders(orgId?: string) {
|
||||||
@@ -28,11 +29,22 @@ export default async function Page({
|
|||||||
|
|
||||||
const loginName = searchParams?.loginName;
|
const loginName = searchParams?.loginName;
|
||||||
const authRequestId = searchParams?.authRequestId;
|
const authRequestId = searchParams?.authRequestId;
|
||||||
const organization = searchParams?.organization;
|
let organization = searchParams?.organization;
|
||||||
const submit: boolean = searchParams?.submit === "true";
|
const submit: boolean = searchParams?.submit === "true";
|
||||||
|
|
||||||
|
if (!organization) {
|
||||||
|
const org: Organization | null = await getDefaultOrg().catch((error) => {
|
||||||
|
console.warn(error);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
if (!org) {
|
||||||
|
console.warn("No default organization found");
|
||||||
|
} else {
|
||||||
|
organization = org.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const loginSettings = await getLoginSettings(organization);
|
const loginSettings = await getLoginSettings(organization);
|
||||||
const legal = await getLegalAndSupportSettings();
|
|
||||||
|
|
||||||
const identityProviders = await getIdentityProviders(organization);
|
const identityProviders = await getIdentityProviders(organization);
|
||||||
|
|
||||||
@@ -55,7 +67,7 @@ export default async function Page({
|
|||||||
submit={submit}
|
submit={submit}
|
||||||
allowRegister={!!loginSettings?.allowRegister}
|
allowRegister={!!loginSettings?.allowRegister}
|
||||||
>
|
>
|
||||||
{legal && identityProviders && process.env.ZITADEL_API_URL && (
|
{identityProviders && process.env.ZITADEL_API_URL && (
|
||||||
<SignInWithIdp
|
<SignInWithIdp
|
||||||
host={host}
|
host={host}
|
||||||
identityProviders={identityProviders}
|
identityProviders={identityProviders}
|
||||||
|
|||||||
Reference in New Issue
Block a user