Fix refresh token expiration
This commit is contained in:
parent
6f80ea686e
commit
8e0837f7f4
|
@ -7,7 +7,7 @@ from jose import JWTError, jwt
|
|||
|
||||
from src.db.models import user
|
||||
from src.db.models.token import Token
|
||||
from src.settings import ACCESS_TOKEN_EXPIRATION, JWT_SECRET_TOKEN
|
||||
from src.settings import ACCESS_TOKEN_EXPIRATION, JWT_SECRET_TOKEN, REFRESH_TOKEN_EXPIRATION
|
||||
from src.utils.logging import get_logger
|
||||
|
||||
__all__ = ["AuthErrState", "InvalidTokenError", "create_jwt_token", "invalidate_access_tokens", "resolve_jwt_token"]
|
||||
|
@ -58,7 +58,10 @@ async def create_jwt_token(
|
|||
This will create a signed token and store it in the database.
|
||||
"""
|
||||
issued_at = datetime.now(UTC)
|
||||
expires_at = issued_at + timedelta(seconds=ACCESS_TOKEN_EXPIRATION)
|
||||
if tok_type == "access":
|
||||
expires_at = issued_at + timedelta(seconds=ACCESS_TOKEN_EXPIRATION)
|
||||
else:
|
||||
expires_at = issued_at + timedelta(seconds=REFRESH_TOKEN_EXPIRATION)
|
||||
|
||||
await user.sync()
|
||||
|
||||
|
|
Loading…
Reference in a new issue