mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-16 06:42:06 +00:00
login with idp
This commit is contained in:
@@ -1,5 +1,31 @@
|
||||
import { getLoginSettings, server } from "#/lib/zitadel";
|
||||
import {
|
||||
getLegalAndSupportSettings,
|
||||
getLoginSettings,
|
||||
server,
|
||||
} from "#/lib/zitadel";
|
||||
import { SignInWithIDP } from "#/ui/SignInWithIDP";
|
||||
import UsernameForm from "#/ui/UsernameForm";
|
||||
import {
|
||||
GetActiveIdentityProvidersResponse,
|
||||
IdentityProvider,
|
||||
ZitadelServer,
|
||||
settings,
|
||||
} from "@zitadel/server";
|
||||
|
||||
function getIdentityProviders(
|
||||
server: ZitadelServer,
|
||||
orgId?: string
|
||||
): Promise<IdentityProvider[] | undefined> {
|
||||
const settingsService = settings.getSettings(server);
|
||||
return settingsService
|
||||
.getActiveIdentityProviders(
|
||||
orgId ? { ctx: { orgId } } : { ctx: { instance: true } },
|
||||
{}
|
||||
)
|
||||
.then((resp: GetActiveIdentityProvidersResponse) => {
|
||||
return resp.identityProviders;
|
||||
});
|
||||
}
|
||||
|
||||
export default async function Page({
|
||||
searchParams,
|
||||
@@ -12,6 +38,14 @@ export default async function Page({
|
||||
const submit: boolean = searchParams?.submit === "true";
|
||||
|
||||
const loginSettings = await getLoginSettings(server, organization);
|
||||
const legal = await getLegalAndSupportSettings(server);
|
||||
|
||||
// TODO if org idps should be shown replace emptystring with the orgId.
|
||||
const identityProviders = await getIdentityProviders(server, "");
|
||||
|
||||
const host = process.env.VERCEL_URL
|
||||
? `https://${process.env.VERCEL_URL}`
|
||||
: "http://localhost:3000";
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center space-y-4">
|
||||
@@ -25,6 +59,13 @@ export default async function Page({
|
||||
organization={organization}
|
||||
submit={submit}
|
||||
/>
|
||||
|
||||
{legal && identityProviders && process.env.ZITADEL_API_URL && (
|
||||
<SignInWithIDP
|
||||
host={host}
|
||||
identityProviders={identityProviders}
|
||||
></SignInWithIDP>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user