{"size": 633, "ext": "js", "max_stars_repo_path": "src/redux/reducers/auth.js", "max_stars_repo_name": "mikenthiwa/travela_front", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/redux/reducers/auth.js", "max_issues_repo_name": "mikenthiwa/travela_front", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/redux/reducers/auth.js", "max_forks_repo_name": "mikenthiwa/travela_front", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.8275862069, "max_line_length": 55, "alphanum_fraction": 0.6603475513}
import * as types from '../constants/actionTypes';
import { userDetails } from '../../helper/userDetails';

const initialState = {
  isAuthenticated: userDetails().isAuthenticated,
  user: userDetails().user,
  error: false
};

const auth = (state = initialState, action) => {
  switch (action.type) {
  case types.SET_CURRENT_USER_SUCCESS:
    return {
      ...state,
      isAuthenticated: action.response.isAuthenticated,
      user: action.response.user,
      error: false
    };
  case types.SET_CURRENT_USER_FAILURE:
    return {
      ...state,
      error: true
    };
  default: return state;
  }
};

export default auth;
