| 12345678910111213141516171819202122 |
- import { attachPostRequestListener } from "../../request";
- import { logoutUser } from "../actions/login/loginActions";
-
- export const authenticationMiddlewareInterceptorName =
- "AUTHENTICATION_MIDDLEWARE";
-
- export default ({ dispatch }) =>
- (next) =>
- (action) => {
- attachPostRequestListener((error) => {
- if (!error.response) {
- return Promise.reject(error);
- }
- if (error.response.status === 401) {
- dispatch(logoutUser());
- return Promise.reject(error);
- }
- return Promise.resolve();
- }, authenticationMiddlewareInterceptorName);
-
- next(action);
- };
|