Yaltopia-FIFA/lib/middleware/portal.ts
Kirubel-Kibru-Yaltopia 89440985f1
Some checks failed
Deploy to Cloudflare Workers / deploy (push) Has been cancelled
x
2026-05-24 21:46:10 +03:00

21 lines
786 B
TypeScript

import type { PortalRole } from "@/lib/auth/roles";
import { PORTAL_ROUTES, loginPathForRole } from "@/lib/auth/roles";
export function pathForRole(role: PortalRole | null | undefined) {
if (role === "league_master") return PORTAL_ROUTES.league_master;
if (role === "manager") return PORTAL_ROUTES.manager;
return "/";
}
export function loginForPath(pathname: string) {
if (pathname.startsWith("/master")) return loginPathForRole("league_master");
if (pathname.startsWith("/manager")) return loginPathForRole("manager");
return "/login/manager";
}
export function roleForPath(pathname: string): PortalRole | null {
if (pathname.startsWith("/master")) return "league_master";
if (pathname.startsWith("/manager")) return "manager";
return null;
}