diff --git a/app/gabsocial/actions/auth.js b/app/gabsocial/actions/auth.js index 4d2b61d69..8c7753fee 100644 --- a/app/gabsocial/actions/auth.js +++ b/app/gabsocial/actions/auth.js @@ -17,7 +17,7 @@ const noOp = () => () => new Promise(f => f()); function initAuthApp() { return (dispatch, getState) => { const hasToken = hasAppToken(getState); - const action = hasToken ? noOp : createAppAndToken; + const action = hasToken ? verifyApp : createAppAndToken; return dispatch(action()) .catch(error => { dispatch(showAlertForError(error)); @@ -65,6 +65,14 @@ function createAppToken() { }; } +function verifyApp() { + return (dispatch, getState) => { + return api(getState, 'app').get('/api/v1/apps/verify_credentials') + .then (response => dispatch(authAppCreated(response.data))) + .catch(error => dispatch(createAppAndToken())); + }; +} + function createUserToken(username, password) { return (dispatch, getState) => { const app = getState().getIn(['auth', 'app']);