Make login/logout tests compatible with jsdom
[arvados-workbench2.git] / src / services / auth-service / auth-service.ts
index 5a08d3b50961fa0b1f2b73b63f7a0da13e9a2e06..4b213fb06cb727f62bf5c7e02326d56c077d350d 100644 (file)
@@ -2,14 +2,13 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import Axios from "axios";
 import { API_HOST } from "../../common/server-api";
 import { User } from "../../models/user";
 
-const API_TOKEN_KEY = 'apiToken';
-const USER_EMAIL_KEY = 'userEmail';
-const USER_FIRST_NAME_KEY = 'userFirstName';
-const USER_LAST_NAME_KEY = 'userLastName';
+export const API_TOKEN_KEY = 'apiToken';
+export const USER_EMAIL_KEY = 'userEmail';
+export const USER_FIRST_NAME_KEY = 'userFirstName';
+export const USER_LAST_NAME_KEY = 'userLastName';
 
 export default class AuthService {
 
@@ -48,11 +47,11 @@ export default class AuthService {
 
     public login() {
         const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
-        window.location.href = `${API_HOST}/login?return_to=${currentUrl}`;
+        window.location.assign(`${API_HOST}/login?return_to=${currentUrl}`);
     }
 
     public logout() {
         const currentUrl = `${window.location.protocol}//${window.location.host}`;
-        window.location.href = `${API_HOST}/logout?return_to=${currentUrl}`;
+        window.location.assign(`${API_HOST}/logout?return_to=${currentUrl}`);
     }
 }