2017-06-08 13:33:57 +00:00
|
|
|
import { handleActions } from 'redux-actions';
|
2017-06-09 05:22:26 +00:00
|
|
|
import { AUTH } from 'actions/auth';
|
2017-06-08 13:33:57 +00:00
|
|
|
|
|
|
|
const initialState = {
|
2017-06-09 03:26:33 +00:00
|
|
|
isLoggedIn: false,
|
|
|
|
session : {
|
|
|
|
username : '',
|
|
|
|
role: ''
|
|
|
|
}
|
2017-06-08 13:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default handleActions({
|
2017-06-09 03:26:33 +00:00
|
|
|
[AUTH.LOGIN_SUCCESS]: (state, action) => ({
|
|
|
|
...state,
|
|
|
|
isLoggedIn: true,
|
|
|
|
session : {
|
|
|
|
...state.session,
|
|
|
|
username: action.payload.username,
|
|
|
|
role: action.payload.role
|
|
|
|
}
|
|
|
|
}),
|
2017-06-08 13:33:57 +00:00
|
|
|
}, initialState);
|