Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed Feb 22, 2024
1 parent ccfd34b commit 4093629
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NotFound from '../pages/NotFound';
import Home from '../pages/Home';
import Protected from '../pages/Protected';

const useHashPathForLoginCalback = config.oidc.responseMode === 'fragment';
const useHashPathForLoginCalback = config.oidc.responseMode === 'fragment' || !config.oidc.pkce;

const NotFoundWithLoginCallback = (props: any) => (
<LoginCallback>
Expand All @@ -37,7 +37,7 @@ const HomeWithLoginCallback = (props: any) => {
};

// NOTE:
// * If using `responseMode: 'fragment'` in OktaAuth config,
// * If using `responseMode: 'fragment'` (or `pkce: false`) in OktaAuth config,
// <LoginCallback> *must* be mounted on '*' with a fallback to 404 component
// * If using 'query' response mode,
// <LoginCallback> *must* be mounted on '/' with a fallback to home component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const profileLoader: LoaderFunction = () => {
// Do NOT return `waitForAuthenticated` promise in `loader` function.
// react-router 6 blocks rendering of all route elements until matching loaders are resolved.
// This means that <Security> component would not be rendered and OktaAuth would not start.
// Without rendering <Security> component `waitForAuthenticated` would NOT be resolved!
// Without rendering of <Security> component `waitForAuthenticated` would NOT be resolved!
return ({
userClaims: waitForAuthenticated(oktaAuth).then(() => oktaAuth.getUser())
});
Expand Down
2 changes: 1 addition & 1 deletion samples/routing/react-router-dom-v6-hash/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React Router v6 createBrowserRouter Sample</title>
<title>React Router v6 HashRouter Sample</title>
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Home from '../pages/Home';
import Protected from '../pages/Protected';
import NotFound from '../pages/NotFound';

const useHashPathForLoginCalback = config.oidc.responseMode === 'fragment';
const useHashPathForLoginCalback = config.oidc.responseMode === 'fragment' || !config.oidc.pkce;

const NotFoundWithLoginCallback = () => (
<LoginCallback>
Expand All @@ -36,12 +36,12 @@ const HomeWithLoginCallback = () => {
};

// NOTE:
// * If using `responseMode: 'fragment'` in OktaAuth config,
// * If using `responseMode: 'fragment'` (or `pkce: false`) in OktaAuth config,
// <LoginCallback> *must* be mounted on '*' with a fallback to 404 component
// Because signin redirect URL is like
// Because in this case a signin redirect URL is like
// 'https://<your-host>/#id_token=...&access_token=...&token_type=Bearer&expires_in=3600&scope=...&state=...'
// and HashRouter in react-router 6 is unable to find any route matching such location
// except for root splat route (<Route path="*">)
// except for "catch-all" route (<Route path="*">)
// * If using 'query' response mode,
// <LoginCallback> *must* be mounted on '/' with a fallback to home component
// Signin redirect URL in this case is 'https://<your-host>/?code=...&state=...'
Expand Down

0 comments on commit 4093629

Please sign in to comment.