sforkowany z mirror/soapbox
Make app repair itself if broken
rodzic
44f196fa99
commit
db7cfacff1
|
@ -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']);
|
||||
|
|
Ładowanie…
Reference in New Issue