forked from wangziqi/gongxue-base
fix: tighten H5 portal guard and legacy home stats
This commit is contained in:
@@ -50,8 +50,17 @@ function isPublicPath(path: string) {
|
||||
return path === '/pages/bootstrap/index' || path === '/pages/student/login/index';
|
||||
}
|
||||
|
||||
export function isPathAllowedForPortal(path: string) {
|
||||
if (isPublicPath(path)) return true;
|
||||
if (!path.startsWith('/pages/')) return true;
|
||||
if (appEnv.portal === 'tenant-admin') return path.startsWith('/pages/tenant-admin/');
|
||||
if (appEnv.portal === 'platform-admin') return path.startsWith('/pages/platform-admin/');
|
||||
return path.startsWith('/pages/student/');
|
||||
}
|
||||
|
||||
export function shouldGuardPath(path: string) {
|
||||
if (isPublicPath(path)) return false;
|
||||
if (!isPathAllowedForPortal(path)) return true;
|
||||
if (appEnv.portal === 'tenant-admin') return path.startsWith('/pages/tenant-admin/');
|
||||
if (appEnv.portal === 'platform-admin') return path.startsWith('/pages/platform-admin/');
|
||||
return path.startsWith('/pages/student/') && path !== '/pages/student/region/index';
|
||||
@@ -107,6 +116,10 @@ export async function guardCurrentRoute() {
|
||||
await ensureRuntimeConfigLoaded();
|
||||
const path = currentPagePath();
|
||||
if (!path || !shouldGuardPath(path)) return true;
|
||||
if (!isPathAllowedForPortal(path)) {
|
||||
redirectToAuthUrl(`/pages/bootstrap/index?redirect=${encodeURIComponent(landingPath())}`);
|
||||
return false;
|
||||
}
|
||||
if (pendingGuardPath === path) return false;
|
||||
pendingGuardPath = path;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user