Merge branch '16159-logout-request-with-token'
[arvados-workbench2.git] / src / services / auth-service / auth-service.ts
index d075a734e2cc61ffb3359e66dbf4ef56a7868387..bd4bc1969c5004d1506f39b3d5a233d748d2fa57 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,13 +98,14 @@ 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}`);
     }
 
-    public logout() {
+    public logout(expireToken: string) {
         const currentUrl = `${window.location.protocol}//${window.location.host}`;
-        window.location.assign(`${this.baseUrl || ""}/logout?return_to=${currentUrl}`);
+        window.location.assign(`${this.baseUrl || ""}/logout?api_token=${expireToken}&return_to=${currentUrl}`);
     }
 
     public getUserDetails = (showErrors?: boolean): Promise<User> => {