浏览代码

Feat/add admin check (#11050)

Dr.MerdanBay 8 月之前
父节点
当前提交
41772c325f
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      api/models/account.py

+ 8 - 0
api/models/account.py

@@ -109,6 +109,10 @@ class Account(UserMixin, db.Model):
         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)
 
@@ -148,6 +152,10 @@ class TenantAccountRole(enum.StrEnum):
         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 {
             TenantAccountRole.ADMIN,