diff --git a/src/features/auth/authSlice.ts b/src/features/auth/authSlice.ts index db25bfa2d1..2158bf9174 100644 --- a/src/features/auth/authSlice.ts +++ b/src/features/auth/authSlice.ts @@ -197,8 +197,9 @@ export const login = export const getSite = () => async (dispatch: AppDispatch, getState: () => RootState) => { const jwtPayload = jwtPayloadSelector(getState()); + const handle = handleSelector(getState()); - if (!jwtPayload) return; + if (!jwtPayload || !handle) return; const { iss } = jwtPayload; @@ -206,6 +207,12 @@ export const getSite = auth: jwtSelector(getState()), }); + // JWT was revoked or invalid, log out user + if (!details.my_user) { + await dispatch(logoutAccount(handle)); + return; + } + dispatch(updateUserDetails(details)); };