Add AuthService constructor with serverApi param
[arvados-workbench2.git] / src / services / auth-service / auth-service.ts
index e953a75d14aabbcd52a2d61fcf32e260d83717f3..5b21a61634be451a75841435e156e265ab0136a7 100644 (file)
@@ -2,8 +2,9 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { API_HOST, serverApi } from "../../common/api/server-api";
+import { API_HOST } from "../../common/api/server-api";
 import { User } from "../../models/user";
+import { AxiosInstance } from "../../../node_modules/axios";
 
 export const API_TOKEN_KEY = 'apiToken';
 export const USER_EMAIL_KEY = 'userEmail';
@@ -23,6 +24,8 @@ export interface UserDetailsResponse {
 
 export default class AuthService {
 
+    constructor(protected serverApi: AxiosInstance) { }
+
     public saveApiToken(token: string) {
         localStorage.setItem(API_TOKEN_KEY, token);
     }
@@ -82,7 +85,7 @@ export default class AuthService {
     }
 
     public getUserDetails = (): Promise<User> => {
-        return serverApi
+        return this.serverApi
             .get<UserDetailsResponse>('/users/current')
             .then(resp => ({
                 email: resp.data.email,