mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: init routes protection
This commit is contained in:
parent
49b6d1dfe7
commit
1ad8ee12b1
25 changed files with 82 additions and 64 deletions
14
front/services/utils/react/middlewares/views.ts
Normal file
14
front/services/utils/react/middlewares/views.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context";
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue