extract enum type for tenant account role (#3788)
This commit is contained in:
parent
cde87cb225
commit
c54fcfb45d
6 changed files with 36 additions and 12 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue