Переглянути джерело

Feat/add admin check (#11050)

tags/0.12.0
Dr.MerdanBay 11 місяці тому
джерело
коміт
41772c325f
Аккаунт користувача з таким Email не знайдено
1 змінених файлів з 8 додано та 0 видалено
  1. 8
    0
      api/models/account.py

+ 8
- 0
api/models/account.py Переглянути файл

@@ -108,6 +108,10 @@ class Account(UserMixin, db.Model):
def is_admin_or_owner(self):
return TenantAccountRole.is_privileged_role(self._current_tenant.current_role)

@property
def is_admin(self):
return TenantAccountRole.is_admin_role(self._current_tenant.current_role)

@property
def is_editor(self):
return TenantAccountRole.is_editing_role(self._current_tenant.current_role)
@@ -147,6 +151,10 @@ class TenantAccountRole(enum.StrEnum):
def is_privileged_role(role: str) -> bool:
return role and role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN}

@staticmethod
def is_admin_role(role: str) -> bool:
return role and role == TenantAccountRole.ADMIN

@staticmethod
def is_non_owner_role(role: str) -> bool:
return role and role in {

Завантаження…
Відмінити
Зберегти