learnhouse/front/services/utils/react/middlewares/views.ts
2023-09-19 20:03:08 +02:00

13 lines
445 B
TypeScript

import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { NextRouter } from "next/router";
export const denyAccessToUser = (error: any, router: AppRouterInstance) => {
if (error.status === 401) {
router.push("/login");
}
if (error.status === 403) {
router.push("/login");
// TODO : add a message to the user to tell him he is not allowed to access this page, route to /error
}
};