Skip to content

Commit

Permalink
[STCOR-876] Remember requested URL path on Login (Regression bug) (#1526
Browse files Browse the repository at this point in the history
)

* Ensure setUnauthorizedPathToSession is called in AuthnLogin to remember requested path on login

* Also remember URL params
  • Loading branch information
ryandberger committed Aug 23, 2024
1 parent 54e5eff commit d3f2c20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/RootWithIntl.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAut
/>
<TitledRoute
name="login"
path="*"
component={<AuthnLogin stripes={connectedStripes} />}
/>
</Switch>
Expand Down
6 changes: 3 additions & 3 deletions src/components/AuthnLogin/AuthnLogin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useLayoutEffect } from 'react';
import PropTypes from 'prop-types';
import Redirect from '../Redirect';
import PreLoginLanding from '../PreLoginLanding';
Expand All @@ -18,7 +18,7 @@ const AuthnLogin = ({ stripes }) => {
stripes.store.dispatch(setOkapiTenant({ tenant, clientId }));
};

useEffect(() => {
useLayoutEffect(() => {
/**
* Cache the current path so we can return to it after authenticating.
* In RootWithIntl, unauthenticated visits to protected paths will be
Expand All @@ -36,7 +36,7 @@ const AuthnLogin = ({ stripes }) => {
* @see OIDCRedirect
*/
if (okapi.authnUrl && window.location.pathname !== '/') {
setUnauthorizedPathToSession(window.location.pathname);
setUnauthorizedPathToSession(window.location.pathname + window.location.search);
}

// If only 1 tenant is defined in config (in either okapi or config.tenantOptions) set to okapi to be accessed there
Expand Down

0 comments on commit d3f2c20

Please sign in to comment.