Skip to content

Commit

Permalink
Moving removeUnauthorizedPathFromSession() to OIDCRedirect so the val…
Browse files Browse the repository at this point in the history
…ue is cleared right after being used rather than on logout
  • Loading branch information
ryandberger committed Sep 9, 2024
1 parent f176c0f commit 00c40bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/components/OIDCRedirect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { withRouter, Redirect, useLocation } from 'react-router';
import queryString from 'query-string';
import { useStripes } from '../StripesContext';
import { getUnauthorizedPathFromSession } from '../loginServices';
import { getUnauthorizedPathFromSession, removeUnauthorizedPathFromSession } from '../loginServices';

const unauthorizedPath = getUnauthorizedPathFromSession();

/**
* OIDCRedirect authenticated route handler for /oidc-landing.
Expand Down Expand Up @@ -29,8 +31,10 @@ const OIDCRedirect = () => {

const getUrl = () => {
if (stripes.okapi.authnUrl) {
const unauthorizedPath = getUnauthorizedPathFromSession();
if (unauthorizedPath) return unauthorizedPath;
if (unauthorizedPath) {
removeUnauthorizedPathFromSession();
return unauthorizedPath;
}
}

const params = getParams();
Expand Down
3 changes: 0 additions & 3 deletions src/loginServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,6 @@ export async function logout(okapiUrl, store) {
localStorage.removeItem(SESSION_NAME);
localStorage.removeItem(RTR_TIMEOUT_EVENT);

// Clear saved entry path so that subsequent logins will use default base URL.
removeUnauthorizedPathFromSession();

store.dispatch(setIsAuthenticated(false));
store.dispatch(clearCurrentUser());
store.dispatch(clearOkapiToken());
Expand Down

0 comments on commit 00c40bd

Please sign in to comment.