mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 02:43:17 +02:00
Added guests.
This commit is contained in:
1 parent
6743dd7626
commit
9736a55e00
10 files changed
+200
-84
No files matched your search
+12
-5
@@ -10,6 +10,8 @@ from Settings import GetDataDirectory
|
||||
|
||||
|
||||
AdminGroupName = "Admin"
|
||||
GuestGroupName = "Guest"
|
||||
BuiltinGroupNames = (AdminGroupName, GuestGroupName)
|
||||
|
||||
|
||||
def GetGroupsPath():
|
||||
@@ -25,7 +27,7 @@ def LoadGroups() -> dict[str, list[str]]:
|
||||
SeededAdmins = [
|
||||
Username for Username, Data in LoadUsers().items() if Data.get("IsAdmin", False)
|
||||
]
|
||||
Groups = {AdminGroupName: SeededAdmins}
|
||||
Groups = {AdminGroupName: SeededAdmins, GuestGroupName: []}
|
||||
SaveGroups(Groups)
|
||||
return Groups
|
||||
|
||||
@@ -33,9 +35,14 @@ def LoadGroups() -> dict[str, list[str]]:
|
||||
Loaded = tomllib.load(GroupsFile)
|
||||
|
||||
Groups = Loaded.get("Groups", {})
|
||||
Changed = False
|
||||
|
||||
if AdminGroupName not in Groups:
|
||||
Groups[AdminGroupName] = []
|
||||
for BuiltinName in BuiltinGroupNames:
|
||||
if BuiltinName not in Groups:
|
||||
Groups[BuiltinName] = []
|
||||
Changed = True
|
||||
|
||||
if Changed:
|
||||
SaveGroups(Groups)
|
||||
|
||||
return Groups
|
||||
@@ -69,8 +76,8 @@ def CreateGroup(Name: str) -> None:
|
||||
|
||||
|
||||
def DeleteGroup(Name: str) -> None:
|
||||
if Name == AdminGroupName:
|
||||
raise ValueError("The Admin group can't be deleted.")
|
||||
if Name in BuiltinGroupNames:
|
||||
raise ValueError(f"The {Name} group can't be deleted.")
|
||||
|
||||
Groups = LoadGroups()
|
||||
|
||||
|
||||
Reference in new issue
Block a user