From d3f2c20442823166756af437b46c69efaf4bd8ff Mon Sep 17 00:00:00 2001 From: Ryan Berger Date: Fri, 23 Aug 2024 12:31:52 -0400 Subject: [PATCH] [STCOR-876] Remember requested URL path on Login (Regression bug) (#1526) * Ensure setUnauthorizedPathToSession is called in AuthnLogin to remember requested path on login * Also remember URL params --- src/RootWithIntl.js | 1 + src/components/AuthnLogin/AuthnLogin.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/RootWithIntl.js b/src/RootWithIntl.js index b51265cc..94f0702a 100644 --- a/src/RootWithIntl.js +++ b/src/RootWithIntl.js @@ -163,6 +163,7 @@ const RootWithIntl = ({ stripes, token = '', isAuthenticated = false, disableAut /> } /> diff --git a/src/components/AuthnLogin/AuthnLogin.js b/src/components/AuthnLogin/AuthnLogin.js index 093c3db6..2d9c92cf 100644 --- a/src/components/AuthnLogin/AuthnLogin.js +++ b/src/components/AuthnLogin/AuthnLogin.js @@ -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'; @@ -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 @@ -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