1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { getType } from "typesafe-actions";
6 import actions, { AuthAction } from "./auth-action";
7 import { User } from "../models/user";
8 import { authService } from "../services/services";
10 type AuthState = User | {};
12 const authReducer = (state: AuthState = {}, action: AuthAction) => {
13 switch (action.type) {
14 case getType(actions.saveApiToken): {
15 authService.saveApiToken(action.payload);
16 return {...state, apiToken: action.payload};
18 case getType(actions.login): {
22 case getType(actions.logout): {
24 return {...state, apiToken: null };
31 export default authReducer;