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 { authService } from "../../services/services";
8 import { User } from "../../models/user";
10 export const authActions = unionize({
11 SAVE_API_TOKEN: ofType<string>(),
15 USER_DETAILS_REQUEST: {},
16 USER_DETAILS_SUCCESS: ofType<User>()
22 export const getUserDetails = () => (dispatch: Dispatch): Promise<User> => {
23 dispatch(authActions.USER_DETAILS_REQUEST());
24 return authService.getUserDetails().then(details => {
25 dispatch(authActions.USER_DETAILS_SUCCESS(details));
30 export type AuthAction = UnionOf<typeof authActions>;