Protecting Routes

  • Next step is to protect the routes, meaning that the user has to be logged in, in order to be able to perform certain operations

  • To do that we will have to modify the function parameters:

def delete_post(id: int, db: Session = Depends(get_db), user_id: int = Depends(oauth2.get_current_user)):
  • So all this does really, is that it sets up the get_current_user function as a dependency meaning that the user has to be logged in

Last updated