Function
authReducer
(state = initialState, action = {})
Source from the content-addressed store, hash-verified
| 26 | }; |
| 27 | |
| 28 | export const authReducer = (state = initialState, action = {}) => { |
| 29 | switch (action.type) { |
| 30 | case LOGIN.PENDING: |
| 31 | return { |
| 32 | ...state, |
| 33 | isLoggingIn: true, |
| 34 | isAuthenticated: false, |
| 35 | }; |
| 36 | case LOGIN.SUCCESS: |
| 37 | return { |
| 38 | ...state, |
| 39 | isLoggingIn: false, |
| 40 | isAuthenticated: true, |
| 41 | accessToken: action.payload, |
| 42 | }; |
| 43 | case LOGIN.ERROR: |
| 44 | return { |
| 45 | ...state, |
| 46 | isLoggingIn: false, |
| 47 | isAuthenticated: false, |
| 48 | error: action.payload, |
| 49 | }; |
| 50 | case LOGOUT.PENDING: |
| 51 | return { |
| 52 | ...state, |
| 53 | isSigningOut: true, |
| 54 | }; |
| 55 | case LOGOUT.SUCCESS: |
| 56 | return { |
| 57 | ...initialState, |
| 58 | hasInitialUser: false, |
| 59 | }; |
| 60 | case LOGOUT.ERROR: |
| 61 | return { |
| 62 | ...state, |
| 63 | isSigningOut: false, |
| 64 | error: action.payload, |
| 65 | }; |
| 66 | case GET_AUTH_USER.PENDING: |
| 67 | return { |
| 68 | ...state, |
| 69 | isPendingUser: true, |
| 70 | }; |
| 71 | case GET_AUTH_USER.SUCCESS: |
| 72 | return { |
| 73 | ...state, |
| 74 | isPendingUser: false, |
| 75 | hasInitialUser: true, |
| 76 | user: action.payload, |
| 77 | }; |
| 78 | case GET_AUTH_USER.ERROR: |
| 79 | return { |
| 80 | ...state, |
| 81 | isPendingUser: false, |
| 82 | error: action.payload, |
| 83 | }; |
| 84 | case GET_AUTH_STAR_COUNT.PENDING: |
| 85 | return { |
Tested by
no test coverage detected