get_domains 改修
This commit is contained in:
@@ -254,17 +254,20 @@ async def flow_delete(
|
||||
raise APIException('platform:flow',request.url._url,f"Error occurred while delete flow:",e)
|
||||
|
||||
@r.get(
|
||||
"/domains/{tenantid}",
|
||||
"/domains",
|
||||
response_model=List[Domain],
|
||||
response_model_exclude_none=True,
|
||||
)
|
||||
async def domain_details(
|
||||
request: Request,
|
||||
tenantid:str,
|
||||
user=Depends(get_current_active_user),
|
||||
db=Depends(get_db),
|
||||
):
|
||||
try:
|
||||
domains = get_domains(db,tenantid)
|
||||
if user.is_superuser:
|
||||
domains =get_alldomains(db)
|
||||
else:
|
||||
domains = get_domains(db,user.id)
|
||||
return domains
|
||||
except Exception as e:
|
||||
raise APIException('platform:domains',request.url._url,f"Error occurred while get domains:",e)
|
||||
|
||||
@@ -3,6 +3,7 @@ import typing as t
|
||||
|
||||
from app.db.session import get_db
|
||||
from app.db.crud import (
|
||||
get_allusers,
|
||||
get_users,
|
||||
get_user,
|
||||
create_user,
|
||||
@@ -30,7 +31,10 @@ async def users_list(
|
||||
"""
|
||||
Get all users
|
||||
"""
|
||||
users = get_users(db,current_user.is_superuser)
|
||||
if current_user.is_superuser:
|
||||
users = get_allusers(db)
|
||||
else:
|
||||
users = get_users(db)
|
||||
# This is necessary for react-admin to work
|
||||
#response.headers["Content-Range"] = f"0-9/{len(users)}"
|
||||
return users
|
||||
|
||||
Reference in New Issue
Block a user