access token ok

This commit is contained in:
2023-10-12 23:01:51 +02:00
parent 6efe9fb5a7
commit 08758aa12f
2 changed files with 7 additions and 5 deletions

View File

@@ -1,7 +1,9 @@
from datetime import datetime, timedelta
from typing import Annotated
from fastapi import Depends, FastAPI, HTTPException, status, APIRouter
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from ..dependencies import fake_users, authenticate_user
from ..dependencies import fake_users, authenticate_user, ACCESS_TOKEN_EXPIRE_MINUTES, create_access_token
from ..models import token
router = APIRouter()
@@ -18,7 +20,7 @@ async def login_for_access_token(
detail="Incorrect username or password",
headers={"WWW-Authenticate": "Bearer"},
)
access_token_expires = timedelta(minutes=dependencies.ACCESS_TOKEN_EXPIRE_MINUTES)
access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
access_token = create_access_token(
data={"sub": user.username}, expires_delta=access_token_expires
)