merge-conflicts
[arvados-workbench2.git] / src / store / auth / auth-action.ts
index e18c78b106f8578b2d396127c74f486f3d62d2ff..a6e6f79794db27bc64178b6f53626c6e688c3865 100644 (file)
@@ -3,7 +3,9 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { ofType, default as unionize, UnionOf } from "unionize";
-import { UserDetailsResponse } from "../../services/auth-service/auth-service";
+import { Dispatch } from "redux";
+import { authService } from "../../services/services";
+import { User } from "../../models/user";
 
 const actions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -11,11 +13,20 @@ const actions = unionize({
     LOGOUT: {},
     INIT: {},
     USER_DETAILS_REQUEST: {},
-    USER_DETAILS_SUCCESS: ofType<UserDetailsResponse>()
+    USER_DETAILS_SUCCESS: ofType<User>()
 }, {
     tag: 'type',
     value: 'payload'
 });
 
+export const getUserDetails = () => (dispatch: Dispatch): Promise<User> => {
+    dispatch(actions.USER_DETAILS_REQUEST());
+    return authService.getUserDetails().then(details => {
+        dispatch(actions.USER_DETAILS_SUCCESS(details));
+        return details;
+    });
+};
+
+
 export type AuthAction = UnionOf<typeof actions>;
 export default actions;