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