Added groups and restricted access.

This commit is contained in:
sarah committed 2026-09-21 06:52:31 +02:00
1 parent 8aa223bc7b
commit 9a5b9530a3
17 files changed
+1406 -66

No files matched your search

+7 -1
View File
@@ -6,6 +6,7 @@ from typing import Any
from fastapi import Depends, HTTPException, Request
from Groups import AdminGroupName, GetGroupsForUser, IsUserInGroup
from Users import GetUser
@@ -39,9 +40,14 @@ def GetCurrentUser(request: Request) -> dict[str, Any]:
if User is None:
raise HTTPException(status_code=401, detail="Session user no longer exists.")
# Admin isn't a stored flag — it's membership in the built-in Admin
# group, computed live, so it behaves exactly like any other group.
UserGroups = GetGroupsForUser(Username)
return {
"Username": Username,
"IsAdmin": User.get("IsAdmin", False),
"IsAdmin": AdminGroupName in UserGroups,
"Groups": UserGroups,
"Colour": User.get("Colour", "Purple"),
}