Created
November 2, 2016 20:15
-
-
Save worst-developer/ad9d9e4e76355536b1ec4d728b253062 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 function checkToken () { | |
return async dispatch => { | |
const response = await httpGet(`/auth/validate-access-token/${localStorage.getItem('AuthToken')}`); | |
if (response.status !== 200) { | |
localStorage.removeItem('AuthToken'); | |
dispatch({ | |
type: Constants.TOKEN_ERROR, | |
error: response.statusText, | |
}); | |
dispatch(push('/signin')); | |
} | |
if (response.status === 200 ) { | |
localStorage.getItem('AuthToken'); | |
dispatch({ | |
type: Constants.TOKEN_VALID, | |
payload: { | |
status: response.status, | |
statusText: 'TOKEN_VALID', | |
} | |
}); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment