mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 02:43:17 +02:00
Added groups and restricted access.
This commit is contained in:
1 parent
8aa223bc7b
commit
9a5b9530a3
17 files changed
+1406
-66
No files matched your search
+7
-1
@@ -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"),
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user