Skip to content

Commit

Permalink
fix - revert Can't handle redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed Feb 23, 2024
1 parent 4093629 commit 7ec4bcc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Nav = () => {
<Link id='protected-nav-link' to='/protected'>Protected</Link>
{isAuthenticated &&
<>
<Link id='protected-nav-link' to='/protected/profile'>Profile</Link>
<Link id='protected-profile-nav-link' to='/protected/profile'>Profile</Link>
</>
}
</nav>
Expand Down
8 changes: 3 additions & 5 deletions src/containers/LoginCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

import * as React from 'react';
import { AuthSdkError } from '@okta/okta-auth-js';
import useLoginCallback, { LoginCallbackOptions } from '../hooks/useLoginCallback';
import useComponents, { ComponentsOptions } from '../hooks/useComponents';
import useOktaAuth from '../context/useOktaAuth';
Expand All @@ -27,13 +26,12 @@ const LoginCallback: React.FC<LoginCallbackProps> = ({
const { ErrorReporter, Loading } = useComponents(oktaContext, options);

if (!isLoginRedirect) {
// This can happen if <LoginCallback> is mounted to a wrong route
// or there are no requried query/hash parameters in the URL
if (children) {
return (<>{children}</>);
} else {
// This can happen if <LoginCallback> is mounted to a wrong route
// or there are no requried query/hash parameters in the URL
const error = new AuthSdkError('Can\'t handle login redirect');
return <ErrorReporter error={error} />;
return null;
}
} else if (callbackError) {
return <ErrorReporter error={callbackError} />;
Expand Down
4 changes: 2 additions & 2 deletions test/jest/specs/loginCallback.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ describe('<LoginCallback />', () => {
isLoginRedirect = false;
});

it('if there are no children, renders error', async () => {
it('if there are no children, renders null', async () => {
const wrapper = mount(
<Security {...mockProps}>
<LoginCallback />
</Security>
);
expect(wrapper.find(LoginCallback).length).toBe(1);
expect(wrapper.text()).toBe('AuthSdkError: Can\'t handle login redirect');
expect(wrapper.text()).toBe('');
});

it('renders children as a fallback', async () => {
Expand Down

0 comments on commit 7ec4bcc

Please sign in to comment.