1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ofType, default as unionize, UnionOf } from "unionize";
6 import { Dispatch } from "redux";
7 import { User } from "../../models/user";
8 import { RootState } from "../store";
9 import { ServiceRepository } from "../../services/services";
11 export const authActions = unionize({
12 SAVE_API_TOKEN: ofType<string>(),
16 USER_DETAILS_REQUEST: {},
17 USER_DETAILS_SUCCESS: ofType<User>()
23 export const getUserDetails = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<User> => {
24 dispatch(authActions.USER_DETAILS_REQUEST());
25 return services.authService.getUserDetails().then(details => {
26 dispatch(authActions.USER_DETAILS_SUCCESS(details));
31 export type AuthAction = UnionOf<typeof authActions>;