From: Lucas Di Pentima Date: Tue, 13 Apr 2021 20:29:24 +0000 (-0300) Subject: 16159: Merge branch 'master' into 16159-logout-request-with-token X-Git-Tag: 2.2.0~15^2 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/c15afcee286bb8ab694f488e2ccd490b56794e47?hp=31e84a9315728c2f58a26bf0e9e1d2b38326fb86 16159: Merge branch 'master' into 16159-logout-request-with-token Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts index 8d27b5bb..bd4bc196 100644 --- a/src/services/auth-service/auth-service.ts +++ b/src/services/auth-service/auth-service.ts @@ -103,9 +103,9 @@ export class AuthService { 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 => { diff --git a/src/store/auth/auth-middleware.test.ts b/src/store/auth/auth-middleware.test.ts index bcc942e1..1438cab3 100644 --- a/src/store/auth/auth-middleware.test.ts +++ b/src/store/auth/auth-middleware.test.ts @@ -38,7 +38,7 @@ describe("AuthMiddleware", () => { const middleware = authMiddleware(services)(store)(next); middleware(authActions.LOGOUT({deleteLinkData: false})); expect(window.location.assign).toBeCalledWith( - `/logout?return_to=${location.protocol}//${location.host}` + `/logout?api_token=someToken&return_to=${location.protocol}//${location.host}` ); expect(localStorage.getItem(API_TOKEN_KEY)).toBeFalsy(); }); diff --git a/src/store/auth/auth-middleware.ts b/src/store/auth/auth-middleware.ts index 6eef5e5e..ce7cd5cb 100644 --- a/src/store/auth/auth-middleware.ts +++ b/src/store/auth/auth-middleware.ts @@ -64,11 +64,12 @@ export const authMiddleware = (services: ServiceRepository): Middleware => store if (deleteLinkData) { services.linkAccountService.removeAccountToLink(); } + const token = services.authService.getApiToken(); services.authService.removeApiToken(); services.authService.removeSessions(); services.authService.removeUser(); removeAuthorizationHeader(services); - services.authService.logout(); + services.authService.logout(token || ''); }, default: () => next(action) });