From: Lucas Di Pentima Date: Wed, 14 Apr 2021 13:33:32 +0000 (-0300) Subject: Merge branch '16159-logout-request-with-token' X-Git-Tag: 2.2.0~15 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/547664ecb6ac881103fb9e94a51b2a2746b2c6ae?hp=274f2f9408e4553643af1b8154050f052132714e Merge branch '16159-logout-request-with-token' Closes #16159 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) });