|
|
@@ -30,7 +30,7 @@ def create_user( |
|
|
|
if user.Role not in settings.ALLOWED_ROLES: |
|
|
|
raise HTTPException( |
|
|
|
status_code=400, |
|
|
|
detail=f"Status {status} is not allowed. Allowed status are {settings.ALLOWED_TASK_STATUS}", |
|
|
|
detail=f"Role {user.Role} is not allowed. Allowed roles are {settings.ALLOWED_ROLES}", |
|
|
|
) |
|
|
|
if current_user.Role != "Admin": |
|
|
|
raise HTTPException( |
|
|
@@ -76,7 +76,9 @@ def update_user( |
|
|
|
raise HTTPException( |
|
|
|
status_code=403, detail="You are not authorized to perform this action" |
|
|
|
) |
|
|
|
user = replace_user_data(user_id=user_id, user=user, db=db) |
|
|
|
user = replace_user_data(user_id=user_id, user_data=user, db=db) |
|
|
|
if user == "userNotFound": |
|
|
|
raise HTTPException(status_code=404, detail="User not found") |
|
|
|
return user |
|
|
|
|
|
|
|
|
|
|
@@ -91,7 +93,7 @@ def get_user_me( |
|
|
|
|
|
|
|
@router.get("/{user_id}", response_model=ShowUser, status_code=status.HTTP_200_OK) |
|
|
|
def get_user(user_id: int, db: Session = Depends(get_db)): |
|
|
|
user = get_user_by_id(user_id=user_id, db=db) |
|
|
|
user = get_user_by_id(user_id=user_id, role="Any", db=db) |
|
|
|
if not user: |
|
|
|
raise HTTPException(status_code=404, detail="User not found") |
|
|
|
return user |
|
|
|