From 71b4818f1b54d4133db36b23668d79cc8ae33702 Mon Sep 17 00:00:00 2001 From: Ryan Berger Date: Tue, 27 Aug 2024 14:37:47 -0400 Subject: [PATCH] Clean up code surrounding setting UNAUTHORIZED_PATH --- src/components/AuthnLogin/AuthnLogin.js | 2 +- src/loginServices.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/AuthnLogin/AuthnLogin.js b/src/components/AuthnLogin/AuthnLogin.js index 2d9c92cf..1519c59c 100644 --- a/src/components/AuthnLogin/AuthnLogin.js +++ b/src/components/AuthnLogin/AuthnLogin.js @@ -36,7 +36,7 @@ const AuthnLogin = ({ stripes }) => { * @see OIDCRedirect */ if (okapi.authnUrl && window.location.pathname !== '/') { - setUnauthorizedPathToSession(window.location.pathname + window.location.search); + setUnauthorizedPathToSession(); } // If only 1 tenant is defined in config (in either okapi or config.tenantOptions) set to okapi to be accessed there diff --git a/src/loginServices.js b/src/loginServices.js index d30576c4..c2d4780c 100644 --- a/src/loginServices.js +++ b/src/loginServices.js @@ -123,9 +123,9 @@ export const setTokenExpiry = async (te) => { const UNAUTHORIZED_PATH = 'unauthorized_path'; export const removeUnauthorizedPathFromSession = () => sessionStorage.removeItem(UNAUTHORIZED_PATH); export const setUnauthorizedPathToSession = (pathname) => { - const path = pathname ?? `${window.location.pathname}${window.location.search}`; + const path = pathname || `${window.location.pathname}${window.location.search}`; if (!path.startsWith('/logout')) { - sessionStorage.setItem(UNAUTHORIZED_PATH, pathname ?? `${window.location.pathname}${window.location.search}`); + sessionStorage.setItem(UNAUTHORIZED_PATH, path); } }; export const getUnauthorizedPathFromSession = () => sessionStorage.getItem(UNAUTHORIZED_PATH);