Skip to content

Reuse or Deactivate delete /users/{user_id} and how to protect resources #606

Closed Answered by frankie567
migeruj asked this question in Q&A
Discussion options

You must be logged in to vote
  1. There is currently no easy way to remove the DELETE endpoint. Since it's only allowed for superusers, maybe you can keep it and just not use it. If you really want to remove it, you can loop through the routes of the router and remove the one with method delete. Something like this:
users_router = fastapi_users.get_users_router()
users_router.routes = [route for route in users_router.routes if route.name != "delete_user"]
app.include_router(users_router, prefix="/users", tags=["users"])
  1. The library provides a dependency for this. See the docs here: https://frankie567.github.io/fastapi-users/usage/dependency-callables/

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@migeruj
Comment options

Answer selected by migeruj
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants