瀏覽代碼

Feat/add admin check (#11050)

tags/0.12.0
Dr.MerdanBay 11 月之前
父節點
當前提交
41772c325f
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 8 行新增0 行删除
  1. 8
    0
      api/models/account.py

+ 8
- 0
api/models/account.py 查看文件

def is_admin_or_owner(self): def is_admin_or_owner(self):
return TenantAccountRole.is_privileged_role(self._current_tenant.current_role) 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 @property
def is_editor(self): def is_editor(self):
return TenantAccountRole.is_editing_role(self._current_tenant.current_role) return TenantAccountRole.is_editing_role(self._current_tenant.current_role)
def is_privileged_role(role: str) -> bool: def is_privileged_role(role: str) -> bool:
return role and role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN} return role and role in {TenantAccountRole.OWNER, TenantAccountRole.ADMIN}


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

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

Loading…
取消
儲存