[ARVADOS-WORKBENCH2] created: 2.1.0-55-gf8c0598d

Git user git at public.arvados.org
Wed Nov 11 09:18:24 UTC 2020


        at  f8c0598de3b7b55df719b6b5519d044ca256f367 (commit)


commit f8c0598de3b7b55df719b6b5519d044ca256f367
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Wed Nov 11 10:16:59 2020 +0100

    17101: Persisting url before the login process
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts
index 75101711..d075a734 100644
--- a/src/services/auth-service/auth-service.ts
+++ b/src/services/auth-service/auth-service.ts
@@ -10,6 +10,7 @@ import { Session, SessionStatus } from "~/models/session";
 import { Config } from "~/common/config";
 import { uniqBy } from "lodash";
 
+export const TARGET_URL = 'targetURL';
 export const API_TOKEN_KEY = 'apiToken';
 export const USER_EMAIL_KEY = 'userEmail';
 export const USER_FIRST_NAME_KEY = 'userFirstName';
@@ -57,6 +58,14 @@ export class AuthService {
         }
     }
 
+    public removeTargetURL() {
+        this.getStorage().removeItem(TARGET_URL);
+    }
+
+    public getTargetURL() {
+       return this.getStorage().getItem(TARGET_URL);
+    }
+
     public removeApiToken() {
         this.getStorage().removeItem(API_TOKEN_KEY);
     }
@@ -83,11 +92,13 @@ export class AuthService {
         this.getStorage().removeItem(USER_IS_ACTIVE);
         this.getStorage().removeItem(USER_USERNAME);
         this.getStorage().removeItem(USER_PREFS);
+        this.getStorage().removeItem(TARGET_URL);
     }
 
     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);
         window.location.assign(`https://${homeClusterHost}/login?${(uuidPrefix !== homeCluster && homeCluster !== loginCluster) ? "remote=" + uuidPrefix + "&" : ""}return_to=${currentUrl}`);
     }
 
diff --git a/src/views-components/api-token/api-token.tsx b/src/views-components/api-token/api-token.tsx
index e11afa7b..955d6920 100644
--- a/src/views-components/api-token/api-token.tsx
+++ b/src/views-components/api-token/api-token.tsx
@@ -25,7 +25,13 @@ export const ApiToken = connect()(
             const apiToken = getUrlParameter(search, 'api_token');
             const loadMainApp = this.props.loadMainApp;
             this.props.dispatch<any>(saveApiToken(apiToken)).finally(() => {
-                if (loadMainApp) {
+                const redirectURL = this.props.authService.getTargetURL();
+
+                if (redirectURL) {
+                    this.props.authService.removeTargetURL();
+                    window.location.href = redirectURL;
+                }
+                else if (loadMainApp) {
                     if (this.props.dispatch(getAccountLinkData())) {
                         this.props.dispatch(navigateToLinkAccount);
                     }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list