2016-06-24 00:29:55 +02:00
|
|
|
import * as ActionTypes from '../../constants';
|
2016-06-09 22:28:21 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
const user = (state = { authenticated: false }, action) => {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.AUTH_USER:
|
2018-05-05 02:22:39 +02:00
|
|
|
return {
|
|
|
|
...action.user,
|
|
|
|
authenticated: true
|
|
|
|
};
|
2016-08-28 02:46:20 +02:00
|
|
|
case ActionTypes.UNAUTH_USER:
|
|
|
|
return {
|
|
|
|
authenticated: false
|
|
|
|
};
|
2016-06-24 00:29:55 +02:00
|
|
|
case ActionTypes.AUTH_ERROR:
|
|
|
|
return {
|
|
|
|
authenticated: false
|
|
|
|
};
|
2016-10-12 23:19:43 +02:00
|
|
|
case ActionTypes.RESET_PASSWORD_INITIATE:
|
2016-10-18 23:06:53 +02:00
|
|
|
return Object.assign({}, state, { resetPasswordInitiate: true });
|
2016-10-14 18:08:08 +02:00
|
|
|
case ActionTypes.RESET_PASSWORD_RESET:
|
2016-10-18 23:06:53 +02:00
|
|
|
return Object.assign({}, state, { resetPasswordInitiate: false });
|
|
|
|
case ActionTypes.INVALID_RESET_PASSWORD_TOKEN:
|
|
|
|
return Object.assign({}, state, { resetPasswordInvalid: true });
|
2017-06-26 18:48:28 +02:00
|
|
|
case ActionTypes.EMAIL_VERIFICATION_INITIATE:
|
|
|
|
return Object.assign({}, state, { emailVerificationInitiate: true });
|
|
|
|
case ActionTypes.EMAIL_VERIFICATION_VERIFY:
|
|
|
|
return Object.assign({}, state, { emailVerificationTokenState: 'checking' });
|
|
|
|
case ActionTypes.EMAIL_VERIFICATION_VERIFIED:
|
|
|
|
return Object.assign({}, state, { emailVerificationTokenState: 'verified' });
|
|
|
|
case ActionTypes.EMAIL_VERIFICATION_INVALID:
|
|
|
|
return Object.assign({}, state, { emailVerificationTokenState: 'invalid' });
|
2017-03-16 23:25:12 +01:00
|
|
|
case ActionTypes.SETTINGS_UPDATED:
|
|
|
|
return { ...state, ...action.user };
|
2018-10-16 00:22:56 +02:00
|
|
|
case ActionTypes.REMOVED_API_KEY:
|
|
|
|
return { ...state, ...action.user };
|
|
|
|
case ActionTypes.ADDED_API_KEY:
|
|
|
|
return { ...state, ...action.user };
|
2016-06-24 00:29:55 +02:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
2016-06-09 22:28:21 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default user;
|