Created
July 8, 2019 23:58
-
-
Save camwhite/d2fabb5afa969635130683b7331ffb0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getCurrentUser = () => (dispatch, getState) => { | |
const { currentUser } = getState().authenticationRequest | |
if (currentUser) { | |
return dispatch({ | |
type: 'CURRENT_USER_SUCCESS', | |
currentUser | |
}) | |
} | |
dispatch({ | |
type: 'CURRENT_USER_REQUEST' | |
}) | |
return fetchCurrentUser() | |
.then(currentUser => { | |
dispatch({ | |
type: 'CURRENT_USER_SUCCESS', | |
currentUser | |
}) | |
}) | |
.catch(err => { | |
dispatch({ | |
type: 'CURRENT_USER_FAILURE', | |
err: err | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment