Initial commit: mini-erp (backend FastAPI + frontend React/Vite)
Base para el flujo de ramas por cliente. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
commit
ab3c613165
154 files changed
+16872
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import json
|
||||
import os
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
|
||||
MENU_PERMISSIONS_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "menu_permissions.json")
|
||||
|
||||
router = APIRouter(tags=["Permisos"])
|
||||
|
||||
|
||||
def load_permissions() -> dict:
|
||||
if not os.path.exists(MENU_PERMISSIONS_PATH):
|
||||
return {}
|
||||
with open(MENU_PERMISSIONS_PATH, "r") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
@router.get("/api/user/menu")
|
||||
async def get_user_menu(request: Request):
|
||||
webUser = str(getattr(request.state, "webUser", ""))
|
||||
if not webUser:
|
||||
raise HTTPException(status_code=401, detail="Usuario no autenticado")
|
||||
|
||||
permissions = load_permissions()
|
||||
allowed_paths = permissions.get(webUser, [])
|
||||
|
||||
return {"allowedPaths": allowed_paths}
|
||||
Reference in new issue
Block a user