Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

authenticationMiddleware.js 612B

12345678910111213141516171819202122
  1. import { attachPostRequestListener } from "../../request";
  2. import { logoutUser } from "../actions/login/loginActions";
  3. export const authenticationMiddlewareInterceptorName =
  4. "AUTHENTICATION_MIDDLEWARE";
  5. export default ({ dispatch }) =>
  6. (next) =>
  7. (action) => {
  8. attachPostRequestListener((error) => {
  9. if (!error.response) {
  10. return Promise.reject(error);
  11. }
  12. if (error.response.status === 401) {
  13. dispatch(logoutUser());
  14. return Promise.reject(error);
  15. }
  16. return Promise.resolve();
  17. }, authenticationMiddlewareInterceptorName);
  18. next(action);
  19. };