44from fastapi import APIRouter , Depends , HTTPException
55from fastapi .responses import HTMLResponse , JSONResponse
66from fastapi .security import OAuth2PasswordRequestForm
7+
78from app import crud
8- from app .api .deps import CurrentUser , SessionDep , get_current_active_superuser , get_current_user
9+ from app .api .deps import (
10+ CurrentUser ,
11+ SessionDep ,
12+ get_current_active_superuser ,
13+ get_current_user ,
14+ )
915from app .core import security
1016from app .core .config import settings
1117from app .core .security import get_password_hash
12- from app .models import Message , NewPassword , Token , UserPublic
18+ from app .models import Message , NewPassword , UserPublic
1319from app .utils import (
1420 generate_password_reset_token ,
1521 generate_reset_password_email ,
2228
2329@router .post ("/login/access-token" )
2430def login_access_token (
25- session : SessionDep , form_data : Annotated [OAuth2PasswordRequestForm , Depends ()]
31+ session : SessionDep , form_data : Annotated [OAuth2PasswordRequestForm , Depends ()]
2632) -> JSONResponse :
2733 """
2834 OAuth2-compatible token login: get an access token for future requests (sent in an HTTP-only cookie)
@@ -35,7 +41,9 @@ def login_access_token(
3541 elif not user .is_active :
3642 raise HTTPException (status_code = 400 , detail = "Inactive user" )
3743 access_token_expires = timedelta (minutes = settings .ACCESS_TOKEN_EXPIRE_MINUTES )
38- return security .set_auth_cookie (user .id , access_token_expires )
44+ r = security .set_auth_cookie (user .id , access_token_expires )
45+ print (r )
46+ return r
3947
4048
4149@router .post ("/login/test-token" , response_model = UserPublic )
0 commit comments