Merge branch '16005-collections-projects-open-in-new-tab'
authorDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 12 Nov 2020 17:12:56 +0000 (18:12 +0100)
committerDaniel Kutyła <daniel.kutyla@contractors.roche.com>
Thu, 12 Nov 2020 17:13:05 +0000 (18:13 +0100)
closes #16005

Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>

src/services/auth-service/auth-service.ts
src/views-components/api-token/api-token.tsx

index d075a734e2cc61ffb3359e66dbf4ef56a7868387..8d27b5bbe88991a255c56fe92db6461965133c25 100644 (file)
@@ -63,7 +63,7 @@ export class AuthService {
     }
 
     public getTargetURL() {
-       return this.getStorage().getItem(TARGET_URL);
+        return this.getStorage().getItem(TARGET_URL);
     }
 
     public removeApiToken() {
@@ -98,7 +98,8 @@ export class AuthService {
     public login(uuidPrefix: string, homeCluster: string, loginCluster: string, remoteHosts: { [key: string]: string }) {
         const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
         const homeClusterHost = remoteHosts[homeCluster];
-        this.getStorage().setItem(TARGET_URL, window.location.href);
+        const rd = new URL(window.location.href);
+        this.getStorage().setItem(TARGET_URL, rd.pathname + rd.search);
         window.location.assign(`https://${homeClusterHost}/login?${(uuidPrefix !== homeCluster && homeCluster !== loginCluster) ? "remote=" + uuidPrefix + "&" : ""}return_to=${currentUrl}`);
     }
 
index 955d6920984adc84687e9e7a59add73245619ca0..f4b50e36d0fdbb7404ee014db80ec605ce51634b 100644 (file)
@@ -11,6 +11,7 @@ import { AuthService } from "~/services/auth-service/auth-service";
 import { navigateToRootProject, navigateToLinkAccount } from "~/store/navigation/navigation-action";
 import { Config } from "~/common/config";
 import { getAccountLinkData } from "~/store/link-account-panel/link-account-panel-actions";
+import { replace } from "react-router-redux";
 
 interface ApiTokenProps {
     authService: AuthService;
@@ -27,12 +28,12 @@ export const ApiToken = connect()(
             this.props.dispatch<any>(saveApiToken(apiToken)).finally(() => {
                 const redirectURL = this.props.authService.getTargetURL();
 
-                if (redirectURL) {
-                    this.props.authService.removeTargetURL();
-                    window.location.href = redirectURL;
-                }
-                else if (loadMainApp) {
-                    if (this.props.dispatch(getAccountLinkData())) {
+                if (loadMainApp) {
+                    if (redirectURL) {
+                        this.props.authService.removeTargetURL();
+                        this.props.dispatch(replace(redirectURL));
+                    }
+                    else if (this.props.dispatch(getAccountLinkData())) {
                         this.props.dispatch(navigateToLinkAccount);
                     }
                     else {