-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathreducers.js
51 lines (49 loc) · 1.71 KB
/
reducers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as ActionTypes from '../../constants';
const user = (state = { authenticated: false }, action) => {
switch (action.type) {
case ActionTypes.AUTH_USER:
return {
...action.user,
authenticated: true
};
case ActionTypes.UNAUTH_USER:
return {
authenticated: false
};
case ActionTypes.AUTH_ERROR:
return {
authenticated: false
};
case ActionTypes.RESET_PASSWORD_INITIATE:
return Object.assign({}, state, { resetPasswordInitiate: true });
case ActionTypes.RESET_PASSWORD_RESET:
return Object.assign({}, state, { resetPasswordInitiate: false });
case ActionTypes.INVALID_RESET_PASSWORD_TOKEN:
return Object.assign({}, state, { resetPasswordInvalid: true });
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'
});
case ActionTypes.SETTINGS_UPDATED:
return { ...state, ...action.user };
case ActionTypes.API_KEY_REMOVED:
return { ...state, ...action.user };
case ActionTypes.API_KEY_CREATED:
return { ...state, ...action.user };
case ActionTypes.SET_COOKIE_CONSENT:
return { ...state, cookieConsent: action.cookieConsent };
default:
return state;
}
};
export default user;