fixed project admin being able to create superadmin users
This commit is contained in:
@@ -740,6 +740,13 @@ async def update_member_role(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Invalid role id {role_data.role_id}"
|
||||
)
|
||||
|
||||
allowed_role_names = {"editor", "auditor", "admin", "viewer"}
|
||||
if role.role_name not in allowed_role_names:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Project admins cannot assign this role"
|
||||
)
|
||||
|
||||
# Update the user's role
|
||||
from src.repositories import UserRepository
|
||||
@@ -798,6 +805,13 @@ async def create_project_user(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Invalid role id {user_data.role_id}"
|
||||
)
|
||||
|
||||
allowed_role_names = {"editor", "auditor", "admin", "viewer"}
|
||||
if role.role_name not in allowed_role_names:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Project admins cannot create users with this role"
|
||||
)
|
||||
|
||||
# Create user in Keycloak
|
||||
keycloak_sub = await KeycloakAdminService.create_user(
|
||||
|
||||
Reference in New Issue
Block a user