diff --git a/src/services/actions/authRegister.ts b/src/services/actions/authRegister.ts index 3a9504c..7d1d3f4 100644 --- a/src/services/actions/authRegister.ts +++ b/src/services/actions/authRegister.ts @@ -245,8 +245,7 @@ export const getUser: AppThunk = () => (dispatch) => { }) .catch((err) => { if (getCookie('refreshToken')) { - dispatch(updateToken()); - dispatch(getUser()); + dispatch(updateToken(getUser)); } else { dispatch(getUserErrorAction()) } @@ -360,7 +359,7 @@ export const resetPassword: AppThunk = (passwordValue: string, tokenValue: strin }) }; -export const updateToken: AppThunk = () => (dispatch: AppDispatch) => { +export const updateToken: AppThunk = (afterRefresh: AppThunk) => (dispatch) => { dispatch(updateTokenRequestAction()); return fetch(API_URL + "/auth/token", { method: 'POST', @@ -377,6 +376,7 @@ export const updateToken: AppThunk = () => (dispatch: AppDispatch) => { const accessToken = jsonResp.accessToken.split('Bearer ')[1]; setCookie('accessToken', accessToken, { path: '/' }); dispatch(updateTokenSuccessAction()); + dispatch(afterRefresh()); } }) .catch((err) => {