X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/eeb82d50816250cc6287928e6d958affa73880ee..c178bb7bacbb174f6b645e410323dbecd59e1a2c:/src/store/auth/auth-action.ts diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index e18c78b1..a6e6f797 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -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(), @@ -11,11 +13,20 @@ const actions = unionize({ LOGOUT: {}, INIT: {}, USER_DETAILS_REQUEST: {}, - USER_DETAILS_SUCCESS: ofType() + USER_DETAILS_SUCCESS: ofType() }, { tag: 'type', value: 'payload' }); +export const getUserDetails = () => (dispatch: Dispatch): Promise => { + dispatch(actions.USER_DETAILS_REQUEST()); + return authService.getUserDetails().then(details => { + dispatch(actions.USER_DETAILS_SUCCESS(details)); + return details; + }); +}; + + export type AuthAction = UnionOf; export default actions;