mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 05:55:52 +08:00
Feat/add admin check (#11050)
This commit is contained in:
parent
a4fc057a1c
commit
41772c325f
@ -108,6 +108,10 @@ class Account(UserMixin, db.Model):
|
|||||||
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)
|
||||||
@ -147,6 +151,10 @@ class TenantAccountRole(enum.StrEnum):
|
|||||||
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…
x
Reference in New Issue
Block a user