Skip to content

Instantly share code, notes, and snippets.

@mattiamanzati
Created September 26, 2015 20:21
Show Gist options
  • Save mattiamanzati/9b19b2874f833d00c0ed to your computer and use it in GitHub Desktop.
Save mattiamanzati/9b19b2874f833d00c0ed to your computer and use it in GitHub Desktop.
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;
@vanessa
Copy link

vanessa commented Jun 20, 2018

On line 22 wouldn't it be action.user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment