Skip to content

Commit

Permalink
feat: create a route to handle invite keys that includes the customer…
Browse files Browse the repository at this point in the history
… slug (#1200)

The existing universal link route does not contain the enterprise slug, so for unauthenticated users,
the frontend has no knowledge of which customer’s branded logistration for which to redirect.
This is typically relied upon based on the `:enterpriseSlug` route parameter in the URL,
which is missing for the existing universal link route.
This change adds a new invite key route that includes the enterprise slug (but
not under the root loader). This will enable us to produce slug-aware invite
URLs from the admin portal, that receiving learners
can use to become linked to the enterprise via the B2B-specific auth flow (which is customer-aware).
ENT-9428
  • Loading branch information
iloveagent57 authored Sep 30, 2024
1 parent 5f5a7c5 commit ac21d02
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/app/routes/createAppRouter.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ describe('createAppRouter', () => {
usesQueryClient: false,
}],
},
{
currentRoutePath: '/test-enterprise/invite/enterprise-customer-invite-key',
expectedRouteTestId: 'invite',
expectedRouteLoaders: [{
loader: makeEnterpriseInviteLoader,
usesQueryClient: false,
}],
},
{
currentRoutePath: '/test-enterprise',
expectedRouteTestId: 'dashboard',
Expand Down
22 changes: 22 additions & 0 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,28 @@ function getOtherRoutes() {
};
},
},
{
/**
* We want to support a slug-"aware" version of the invite key route,
* but we don't want it nested under the root loader via
* enterpriseSlugRoutes above. Putting this route under the root loader
* would mean that the post-registration redirect back to this route
* would run through the root loader logic with a now-authenticated-but-unlinked
* requesting user, which will throw a 404 (until the async call to
* `link-user/` resolves and the page is reloaded).
*/
path: ':enterpriseSlug/invite/:enterpriseCustomerInviteKey',
lazy: async () => {
const {
default: EnterpriseInviteRoute,
makeEnterpriseInviteLoader,
} = await import('./components/app/routes/EnterpriseInviteRoute');
return {
Component: EnterpriseInviteRoute,
loader: makeEnterpriseInviteLoader(),
};
},
},
];
return otherRoutes;
}
Expand Down

0 comments on commit ac21d02

Please sign in to comment.