Updating the application
Updating the user sign-in route
from fastapi import APIRouter, Depends, HTTPException, status from fastapi.security import OAuth2PasswordRequestForm from auth.jwt_handler import create_access_token from models.users import User
We have imported the
OAuth2PasswordRequestForm class from FastAPI’s security module. This will be injected into the sign-in route to retrieve the credentials sent over: username and password. Let’s update the
sign_user_in() route function:
async def sign_user_in(user: OAuth2PasswordRequestForm = Depends()) -> dict: user_exist = await User.find_one(User.email == user.username) .. ...