mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FIX: Show a json api response when deleting a user with posts
A 500 error was actually caused with no response when using the api, so it wasn't very clear that you need to delete the posts first when using the api.
This commit is contained in:
@ -379,7 +379,10 @@ class Admin::UsersController < Admin::AdminController
|
||||
}
|
||||
end
|
||||
rescue UserDestroyer::PostsExistError
|
||||
raise Discourse::InvalidAccess.new("User #{user.username} has #{user.post_count} posts, so can't be deleted.")
|
||||
render json: {
|
||||
deleted: false,
|
||||
message: "User #{user.username} has #{user.post_count} posts, so they can't be deleted."
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user