mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-14 20:41:21 +08:00
extract enum type for tenant account role (#3788)
This commit is contained in:
@@ -344,9 +344,9 @@ class TenantService:
|
||||
def check_member_permission(tenant: Tenant, operator: Account, member: Account, action: str) -> None:
|
||||
"""Check member permission"""
|
||||
perms = {
|
||||
'add': ['owner', 'admin'],
|
||||
'remove': ['owner'],
|
||||
'update': ['owner']
|
||||
'add': [TenantAccountRole.OWNER, TenantAccountRole.ADMIN],
|
||||
'remove': [TenantAccountRole.OWNER],
|
||||
'update': [TenantAccountRole.OWNER]
|
||||
}
|
||||
if action not in ['add', 'remove', 'update']:
|
||||
raise InvalidActionError("Invalid action.")
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
import requests
|
||||
|
||||
from extensions.ext_database import db
|
||||
from models.account import TenantAccountJoin
|
||||
from models.account import TenantAccountJoin, TenantAccountRole
|
||||
|
||||
|
||||
class BillingService:
|
||||
@@ -74,5 +74,5 @@ class BillingService:
|
||||
TenantAccountJoin.account_id == current_user.id
|
||||
).first()
|
||||
|
||||
if join.role not in ['owner', 'admin']:
|
||||
if TenantAccountRole.is_privileged_role(join.role):
|
||||
raise ValueError('Only team owner or team admin can perform this action')
|
||||
|
||||
Reference in New Issue
Block a user