Skip to content

Commit 0cad636

Browse files
fixes (#810)
1 parent 10e3b61 commit 0cad636

File tree

9 files changed

+19646
-743
lines changed

9 files changed

+19646
-743
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
## [0.39.1] - 2024-03-27
11+
12+
- Fixes how we fetch the component to render based on the current path to take into account non auth recipes correctly.
1013
- Adds Remix example reference.
1114

1215
## [0.39.0] - 2024-03-07

lib/build/genericComponentOverrideContext.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/index2.js

Lines changed: 40 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/version.d.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/recipe/recipeRouter/index.tsx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,35 +164,43 @@ export abstract class RecipeRouter {
164164
routePath === path ||
165165
new RegExp("^" + routePath.replace(/:\w+/g, "[^/]+").replace(/\/\*/g, "/[^/]+") + "$").test(path)
166166
) {
167-
components = components.concat(routeComps);
167+
components = components.concat(
168+
routeComps.map((c) => {
169+
return { comp: c, route: routePath };
170+
})
171+
);
168172
}
169173
}
170174
return components;
171-
}, [] as ComponentWithRecipeAndMatchingMethod[]);
175+
}, [] as { comp: ComponentWithRecipeAndMatchingMethod; route: string }[]);
172176

173177
// We check the query params to see if any recipe was requested by id
174-
const componentMatchingRid = routeComponents.find((c) => c.matches());
178+
const componentMatchingRid = routeComponents.find((c) => c.comp.matches());
175179

176180
// We default to to one requested by id or the first in the list
177181
// i.e.: the first prebuilt ui in the list the user provided that can handle this route.
178-
let defaultComp;
182+
let defaultComp: ComponentWithRecipeAndMatchingMethod | undefined;
179183
if (routeComponents.length === 0) {
180184
defaultComp = undefined;
181185
} else if (componentMatchingRid !== undefined) {
182-
defaultComp = componentMatchingRid;
186+
defaultComp = componentMatchingRid.comp;
183187
} else {
184-
defaultComp = routeComponents[0];
188+
defaultComp = routeComponents[0].comp;
185189
}
186190

187191
// We check if any non-auth recipe (emailverification, totp) can handle this
188192
// There should be no overlap between the routes handled by those and the auth recipes
189193
// so if there is a match we can return early
190-
const matchingNonAuthComponent = routeComponents.find(
191-
(comp) => !priorityOrder.map((a) => a.rid).includes(comp.recipeID)
192-
);
194+
const matchingNonAuthComponent = routeComponents.find((comp) => {
195+
const ridlist = priorityOrder.map((a) => a.rid);
196+
return (
197+
!ridlist.includes(comp.comp.recipeID) ||
198+
comp.route !== SuperTokens.getInstanceOrThrow().appInfo.websiteBasePath.getAsStringDangerous()
199+
);
200+
});
193201

194202
if (matchingNonAuthComponent) {
195-
return matchingNonAuthComponent;
203+
return matchingNonAuthComponent.comp;
196204
}
197205

198206
// We use this option in `canHandleRoute`, because it may be called by custom UIs before
@@ -205,14 +213,17 @@ export abstract class RecipeRouter {
205213
if (SuperTokens.usesDynamicLoginMethods === false) {
206214
// If we are not using dynamic login methods, we can use the rid requested by the app
207215
if (componentMatchingRid) {
208-
return componentMatchingRid;
216+
return componentMatchingRid.comp;
209217
}
210218

211219
// if we have a static firstFactors config we take it into account on the auth page
212220
// Other pages shouldn't care about this configuration.
213221
// Embedded components are not affected, since this is only called by the routing component.
214222
if (isAuthPage && mfaRecipe && mfaRecipe.config.firstFactors !== undefined) {
215-
return chooseComponentBasedOnFirstFactors(mfaRecipe.config.firstFactors, routeComponents);
223+
return chooseComponentBasedOnFirstFactors(
224+
mfaRecipe.config.firstFactors,
225+
routeComponents.map((c) => c.comp)
226+
);
216227
} else {
217228
return defaultComp;
218229
}
@@ -227,21 +238,24 @@ export abstract class RecipeRouter {
227238
// If we are using dynamic login methods, we check that the requested rid belongs to an enabled recipe
228239
if (
229240
componentMatchingRid && // if we find a component matching by rid
230-
(!priorityOrder.map((a) => a.rid).includes(componentMatchingRid.recipeID) || // from a non-auth recipe
241+
(!priorityOrder.map((a) => a.rid).includes(componentMatchingRid.comp.recipeID) || // from a non-auth recipe
231242
priorityOrder.some(
232243
(a) =>
233-
a.rid === componentMatchingRid.recipeID &&
244+
a.rid === componentMatchingRid.comp.recipeID &&
234245
a.factorsProvided.some((factorId) => dynamicLoginMethods.firstFactors.includes(factorId))
235246
)) // or an enabled auth recipe
236247
) {
237-
return componentMatchingRid;
248+
return componentMatchingRid.comp;
238249
}
239250

240251
// if we have a firstFactors config for the tenant we take it into account on the auth page
241252
// Other pages shouldn't care about this configuration.
242253
// Embedded components are not affected, since this is only called by the routing component.
243254
if (isAuthPage) {
244-
return chooseComponentBasedOnFirstFactors(dynamicLoginMethods.firstFactors, routeComponents);
255+
return chooseComponentBasedOnFirstFactors(
256+
dynamicLoginMethods.firstFactors,
257+
routeComponents.map((c) => c.comp)
258+
);
245259
}
246260

247261
return undefined;

lib/ts/recipe/thirdpartypasswordless/prebuiltui.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ export class ThirdPartyPasswordlessPreBuiltUI extends RecipeRouter {
160160
recipeID: ThirdPartyPasswordless.RECIPE_ID,
161161
};
162162
}
163-
164163
return {
165164
...features,
166165
};

lib/ts/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
* License for the specific language governing permissions and limitations
1313
* under the License.
1414
*/
15-
export const package_version = "0.39.0";
15+
export const package_version = "0.39.1";

0 commit comments

Comments
 (0)