corrected the auth.py file
parent
28e992cceb
commit
3737359e30
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, timedelta
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from fastapi import APIRouter, Depends, HTTPException, status, Body
|
||||
from fastapi import APIRouter, Depends, Form, HTTPException, status, Body
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
||||
from sqlalchemy import update, select
|
||||
|
|
@ -31,8 +31,8 @@ async def signup(user: UserCreate, db=Depends(get_db)):
|
|||
return await UserService.create_user(user, db)
|
||||
|
||||
@router.post("/token", response_model=Token, summary="Login and get access token")
|
||||
async def login_for_access_token(username: str, password: str, db=Depends(get_db)):
|
||||
user = await AuthService.authenticate_user(username, password, db)
|
||||
async def login_for_access_token( form_data: OAuth2PasswordRequestForm = Depends(), db=Depends(get_db)):
|
||||
user = await AuthService.authenticate_user(form_data.username, form_data.password, db)
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
|
|
|
|||
Loading…
Reference in New Issue