fix: OIDC Redirect erases query parameters (#1773)

* fix: OIDC Redirect erases query parameters

* prevent issues

Co-authored-by: James Petts <jamesapetts@gmail.com>
This commit is contained in:
Rodrigo Antinarelli 2020-06-15 09:43:10 -03:00 committed by GitHub
parent ab25be3520
commit 6123741765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 10 deletions

View File

@ -52,10 +52,13 @@ class OHIFStandaloneViewer extends Component {
const { appConfig = {} } = this.context;
const userNotLoggedIn = userManager && (!user || user.expired);
if (userNotLoggedIn) {
const pathname = this.props.location.pathname;
const { pathname, search } = this.props.location;
if (pathname !== '/callback') {
sessionStorage.setItem('ohif-redirect-to', pathname);
sessionStorage.setItem(
'ohif-redirect-to',
JSON.stringify({ pathname, search })
);
}
return (
@ -103,12 +106,21 @@ class OHIFStandaloneViewer extends Component {
userManager.removeUser().then(() => {
if (targetLinkUri !== null) {
const ohifRedirectTo = {
pathname: new URL(targetLinkUri).pathname,
};
sessionStorage.setItem(
'ohif-redirect-to',
new URL(targetLinkUri).pathname
JSON.stringify(ohifRedirectTo)
);
} else {
sessionStorage.setItem('ohif-redirect-to', '/');
const ohifRedirectTo = {
pathname: '/',
};
sessionStorage.setItem(
'ohif-redirect-to',
JSON.stringify(ohifRedirectTo)
);
}
if (loginHint !== null) {
@ -191,10 +203,10 @@ class OHIFStandaloneViewer extends Component {
{match === null ? (
<></>
) : (
<ErrorBoundary context={match.url}>
<Component match={match} location={this.props.location} />
</ErrorBoundary>
)}
<ErrorBoundary context={match.url}>
<Component match={match} location={this.props.location} />
</ErrorBoundary>
)}
</CSSTransition>
)}
</Route>

View File

@ -14,9 +14,11 @@ class CallbackPage extends Component {
<CallbackComponent
userManager={this.props.userManager}
successCallback={() => {
const pathname = sessionStorage.getItem('ohif-redirect-to');
const { pathname, search = '' } = JSON.parse(
sessionStorage.getItem('ohif-redirect-to')
);
this.props.history.push(pathname);
this.props.history.push({ pathname, search });
}}
errorCallback={error => {
//this.props.history.push("/");