Navigation fixes
[arvados-workbench2.git] / src / services / auth-service / auth-service.ts
index 07e0ff0913834ebdda8e72e0131332a933ded949..e953a75d14aabbcd52a2d61fcf32e260d83717f3 100644 (file)
@@ -4,8 +4,6 @@
 
 import { API_HOST, serverApi } from "../../common/api/server-api";
 import { User } from "../../models/user";
-import { Dispatch } from "redux";
-import actions from "../../store/auth/auth-action";
 
 export const API_TOKEN_KEY = 'apiToken';
 export const USER_EMAIL_KEY = 'userEmail';
@@ -37,6 +35,10 @@ export default class AuthService {
         return localStorage.getItem(API_TOKEN_KEY) || undefined;
     }
 
+    public getUuid() {
+        return localStorage.getItem(USER_UUID_KEY) || undefined;
+    }
+
     public getOwnerUuid() {
         return localStorage.getItem(USER_OWNER_UUID_KEY) || undefined;
     }
@@ -79,14 +81,17 @@ export default class AuthService {
         window.location.assign(`${API_HOST}/logout?return_to=${currentUrl}`);
     }
 
-    public getUserDetails = () => (dispatch: Dispatch): Promise<void> => {
-        dispatch(actions.USER_DETAILS_REQUEST());
+    public getUserDetails = (): Promise<User> => {
         return serverApi
             .get<UserDetailsResponse>('/users/current')
-            .then(resp => {
-                dispatch(actions.USER_DETAILS_SUCCESS(resp.data));
-            });
-    };
+            .then(resp => ({
+                email: resp.data.email,
+                firstName: resp.data.first_name,
+                lastName: resp.data.last_name,
+                uuid: resp.data.uuid,
+                ownerUuid: resp.data.owner_uuid
+            }));
+    }
 
     public getRootUuid() {
         const uuid = this.getOwnerUuid();