ow
This commit is contained in:
1 parent
6a8258ac4b
commit
a7b25d49c4
29 files changed
+1960
-649
No files matched your search
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
import type { ErrorPageName, PageName } from "@/router/routes";
|
||||
import { getJwtInfo } from "@/common/http.interceptor";
|
||||
import { canVisitPage } from "@/permission/permission-context";
|
||||
import {
|
||||
errorPageUrl,
|
||||
isAuthFree,
|
||||
@@ -32,7 +33,7 @@ function isLoggedIn(): boolean {
|
||||
* 判定目标地址该被拦成哪个错误页;返回 null 表示放行
|
||||
*
|
||||
* 顺序即语义:地址不存在(404) -> 没登录(401) -> 没权限(403)
|
||||
* 403 这层要等 PAGE_PERMISSIONS 与 PermissionContext 移植后接在这里
|
||||
* 403 必须排在 401 之后:未登录时权限档案多半也是空的,先给 401 才谈得上"去登录"
|
||||
*/
|
||||
function evaluate(url: string): ErrorPageName | null {
|
||||
const name: PageName | null = resolvePageName(url);
|
||||
@@ -45,6 +46,9 @@ function evaluate(url: string): ErrorPageName | null {
|
||||
if (!isLoggedIn()) {
|
||||
return "error401";
|
||||
}
|
||||
if (!canVisitPage(name)) {
|
||||
return "error403";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user