Created
September 26, 2015 20:21
-
-
Save mattiamanzati/9b19b2874f833d00c0ed to your computer and use it in GitHub Desktop.
This file contains 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
var { | |
AUTH_SET_TOKEN, | |
AUTH_DISCARD_TOKEN, | |
AUTH_SET_USER | |
} = require('./constants'); | |
function auth(state = {}, action){ | |
switch(action.type){ | |
// saves the token into the state | |
case AUTH_SET_TOKEN: | |
return { | |
...state, | |
token: action.token | |
}; | |
// discards the current token (logout) | |
case AUTH_DISCARD_TOKEN: | |
return {}; | |
// saves the current user | |
case AUTH_SET_USER: | |
return { | |
...state, | |
user | |
}; | |
// as always, on default do nothing | |
default: | |
return state; | |
} | |
} | |
module.exports = auth; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 22 wouldn't it be
action.user
?