lint, cleanup

This commit is contained in:
peintnermax
2024-08-21 14:22:52 +02:00
parent 0ca7fa4ce0
commit 7556c512ba
2 changed files with 17 additions and 9 deletions

View File

@@ -1,5 +1,15 @@
import { getBrandingSettings, PROVIDER_NAME_MAPPING } from "@/lib/zitadel";
import { getBrandingSettings } from "@/lib/zitadel";
import DynamicTheme from "@/ui/DynamicTheme";
import { IdentityProviderType } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
// This configuration shows the given name in the respective IDP button as fallback
const PROVIDER_NAME_MAPPING: {
[provider: string]: string;
} = {
[IdentityProviderType.GOOGLE]: "Google",
[IdentityProviderType.GITHUB]: "GitHub",
[IdentityProviderType.AZURE_AD]: "Microsoft",
};
export default async function Page({
searchParams,

View File

@@ -3,6 +3,7 @@ import { IDPInformation, IDPLink } from "@zitadel/proto/zitadel/user/v2/idp_pb";
import { IdentityProviderType } from "@zitadel/proto/zitadel/settings/v2/login_settings_pb";
import { PartialMessage } from "@zitadel/client";
// This maps the IdentityProviderType to a slug which is used in the /success and /failure routes
export function idpTypeToSlug(idpType: IdentityProviderType) {
switch (idpType) {
case IdentityProviderType.GITHUB:
@@ -20,14 +21,7 @@ export function idpTypeToSlug(idpType: IdentityProviderType) {
}
}
export const PROVIDER_NAME_MAPPING: {
[provider: string]: string;
} = {
[IdentityProviderType.GOOGLE]: "Google",
[IdentityProviderType.GITHUB]: "GitHub",
[IdentityProviderType.AZURE_AD]: "Microsoft",
};
// this maps the IDPInformation to the AddHumanUserRequest which is used when creating a user or linking a user (email)
export const PROVIDER_MAPPING: {
[provider: string]: (
rI: IDPInformation,
@@ -63,6 +57,7 @@ export const PROVIDER_MAPPING: {
},
idpLinks: [idpLink],
};
return req;
},
[idpTypeToSlug(IdentityProviderType.AZURE_AD)]: (idp: IDPInformation) => {
@@ -101,11 +96,13 @@ export const PROVIDER_MAPPING: {
email: string;
name: string;
};
const idpLink: PartialMessage<IDPLink> = {
idpId: idp.idpId,
userId: idp.userId,
userName: idp.userName,
};
const req: PartialMessage<AddHumanUserRequest> = {
username: idp.userName,
email: {
@@ -120,6 +117,7 @@ export const PROVIDER_MAPPING: {
},
idpLinks: [idpLink],
};
return req;
},
};