const isUserAction = /^user/

const user = (state = {}, action) => {
  if (!isUserAction.test(action.type)) return state;

  switch(action.type) {
    case 'user/USER_LOGIN_SUCCESS':
      return {
        authenticated: true,
      };
    case 'user/USER_LOGIN_FAILURE':
      return {
        authenticated: false,
        error: action.error,
      }
    case 'user/GET_USER_DETAILS_SUCCESS':
      return {
        authenticated: true,
        ...action.response,
      };
    case 'user/GET_USER_DETAILS_FAILURE':
      return {
        authenticated: false,
        error: action.error,
      };
    case 'user/USER_LOGOUT':
      return {
        authenticated: false,
      };
    default:
      return state;
  }
};

export default user;

// Selectors
export const getAuthenticated = (state) => state.authenticated;
export const getOsmId = (state) => state.osmid;
export const getUsername = (state) => state.username;
export const getAvatar = (state) => state.avatar;
export const getIsFetching = (state) => state.isFetching;
export const getError = (state) => state.error;

@@ -1,12 +1,108 @@
+import api from '../api';%0A%0Aconst initialState = %7B%0A  authenticated: api.osm.authenticated(),%0A%7D;%0A%0A
 const isUser
@@ -145,10 +145,20 @@
 e = 
-%7B%7D
+initialState
 , ac

set initial state by checking api.osm.authenticated