access token ok
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
Reference in New Issue
Block a user