From 34647fbfb31cf5283f4bafa4b4f487155970446c Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 7 Nov 2024 15:09:06 +0100 Subject: [PATCH] fix: properly apply getSecondaryFactorInfo from user config --- lib/build/multifactorauth-shared2.js | 14 +++++++++----- lib/build/multifactorauthprebuiltui.js | 2 +- .../themes/factorChooser/factorOption.d.ts | 2 +- lib/build/recipe/multifactorauth/types.d.ts | 2 +- .../themes/factorChooser/factorOption.tsx | 4 ++-- lib/ts/recipe/multifactorauth/types.ts | 2 +- lib/ts/recipe/multifactorauth/utils.ts | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/build/multifactorauth-shared2.js b/lib/build/multifactorauth-shared2.js index d5e65825c..551b6ea93 100644 --- a/lib/build/multifactorauth-shared2.js +++ b/lib/build/multifactorauth-shared2.js @@ -317,7 +317,7 @@ var MultiFactorAuthClaimClass = /** @class */ (function () { * under the License. */ function normaliseMultiFactorAuthFeature(config) { - var _a; + var _a, _b; if (config === undefined) { config = {}; } @@ -338,10 +338,14 @@ function normaliseMultiFactorAuthFeature(config) { { disableDefaultUI: disableDefaultUI, firstFactors: config === null || config === void 0 ? void 0 : config.firstFactors, - getSecondaryFactorInfo: function (orig) { - return orig; - }, - factorChooserScreen: (_a = config.factorChooserScreen) !== null && _a !== void 0 ? _a : {}, + getSecondaryFactorInfo: + (_a = config === null || config === void 0 ? void 0 : config.getSecondaryFactorInfo) !== null && + _a !== void 0 + ? _a + : function (orig) { + return orig; + }, + factorChooserScreen: (_b = config.factorChooserScreen) !== null && _b !== void 0 ? _b : {}, override: override, } ); diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index 7685444ea..289fd85e5 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -150,7 +150,7 @@ var FactorOption = uiEntry.withOverride("MFAFactorOption", function MFAFactorOpt "div", genericComponentOverrideContext.__assign( { "data-supertokens": "factorLogo" }, - { children: [" ", logo({})] } + { children: [" ", logo ? logo({}) : null] } ) ), jsxRuntime.jsxs( diff --git a/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts b/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts index a22f99c92..cad0cb91f 100644 --- a/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts +++ b/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts @@ -4,5 +4,5 @@ export declare const FactorOption: import("react").ComponentType<{ id: string; name: string; description: string; - logo: FC; + logo: FC | undefined; }>; diff --git a/lib/build/recipe/multifactorauth/types.d.ts b/lib/build/recipe/multifactorauth/types.d.ts index 025aea3a2..f2cb93697 100644 --- a/lib/build/recipe/multifactorauth/types.d.ts +++ b/lib/build/recipe/multifactorauth/types.d.ts @@ -94,7 +94,7 @@ export declare type SecondaryFactorRedirectionInfo = { id: string; name: string; description: string; - logo: FC; + logo: FC | undefined; path: string; }; export declare const FactorIds: { diff --git a/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorOption.tsx b/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorOption.tsx index 3cf387920..7cfad10ca 100644 --- a/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorOption.tsx +++ b/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorOption.tsx @@ -32,12 +32,12 @@ export const FactorOption = withOverride( id: string; name: string; description: string; - logo: FC; + logo: FC | undefined; }): JSX.Element { const t = useTranslation(); return ( -
{logo({})}
+
{logo ? logo({}) : null}
{t(name)}

{t(description)}

diff --git a/lib/ts/recipe/multifactorauth/types.ts b/lib/ts/recipe/multifactorauth/types.ts index 6dc4b24eb..9f1096fb8 100644 --- a/lib/ts/recipe/multifactorauth/types.ts +++ b/lib/ts/recipe/multifactorauth/types.ts @@ -124,7 +124,7 @@ export type SecondaryFactorRedirectionInfo = { id: string; name: string; description: string; - logo: FC; + logo: FC | undefined; path: string; }; diff --git a/lib/ts/recipe/multifactorauth/utils.ts b/lib/ts/recipe/multifactorauth/utils.ts index fb1934d29..92c4511e3 100644 --- a/lib/ts/recipe/multifactorauth/utils.ts +++ b/lib/ts/recipe/multifactorauth/utils.ts @@ -37,7 +37,7 @@ export function normaliseMultiFactorAuthFeature(config?: Config): NormalisedConf ...normaliseRecipeModuleConfig(config), disableDefaultUI, firstFactors: config?.firstFactors, - getSecondaryFactorInfo: (orig) => orig, + getSecondaryFactorInfo: config?.getSecondaryFactorInfo ?? ((orig) => orig), factorChooserScreen: config.factorChooserScreen ?? {}, override, };