Show only granted gates in menu

This commit is contained in:
2025-05-24 00:08:08 +02:00
parent 5b8cbf8b9f
commit 9af398faef
5 changed files with 35 additions and 8 deletions

View File

@@ -196,3 +196,13 @@ class Users:
grant.last_used_at = datetime.now(timezone.utc)
self._save_users()
return True
def get_granted_gates(self, user_id: str) -> list[str]:
user = self._users.get(user_id)
if not user:
return []
if user.role == Role.ADMIN or user.role == Role.MEMBER:
return ['all']
if 'all' in user.grants and user.grants['all'].status == Status.ENABLED and user.grants['all'].expires_at > datetime.now(timezone.utc):
return ['all']
return [gate for gate, grant in user.grants.items() if grant.status == Status.ENABLED and grant.expires_at > datetime.now(timezone.utc)]