Set cookie on /refresh

This commit is contained in:
Parker M. 2024-11-08 15:13:33 -06:00
parent c13c9ebbbb
commit 3cde652d52
Signed by: parker
GPG Key ID: 505ED36FC12B5D5E

View File

@ -58,6 +58,7 @@ async def login_for_access_token(
@router.post("/refresh") @router.post("/refresh")
async def refresh_access_token( async def refresh_access_token(
current_user: Annotated[User, Depends(refresh_get_current_user)], current_user: Annotated[User, Depends(refresh_get_current_user)],
response: Response,
) -> Token: ) -> Token:
""" """
Return a new access token if the refresh token is valid Return a new access token if the refresh token is valid
@ -67,7 +68,6 @@ async def refresh_access_token(
data={"sub": current_user.id, "refresh": False}, data={"sub": current_user.id, "refresh": False},
expires_delta=access_token_expires, expires_delta=access_token_expires,
) )
return Token( response = JSONResponse(content={"success": True})
access_token=access_token, response.set_cookie(key="access_token", value=access_token, httponly=True)
token_type="bearer", return response
)