Created
December 30, 2015 14:31
-
-
Save karlbright/4e5a6e49f46ca8006289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Immutable from 'immutable' | |
import { LOGIN, LOGIN_SUCCESS, LOGIN_FAILURE } from 'actions/authentication' | |
const initialState = Immutable.Map({ loggedIn: false, loggingIn: false }) | |
export default function authenticationReducer (state = initialState, action) { | |
const pending = state.merge({ loggedIn: false, loggingIn: true }) | |
const success = state.merge({ loggedIn: true, loggingIn: false, token: action.payload.token }) | |
const failure = state.merge({ loggedIn: false, loggingIn: false, error: action.error }) | |
switch (action.type) { | |
case AUTHENTICATE: return pending | |
case AUTHENTICATE_SUCCESS: return success | |
case AUTHENTICATION_FAILURE: return failure | |
case VERIFY_TOKEN: return pending | |
case VERIFY_TOKEN_SUCCESS: return success | |
case VERIFY_TOKEN_FAILURE: return failure | |
default: return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment