mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-14 18:58:10 +08:00
Fix utcnow deprecation warning (#1369)
This commit is contained in:

committed by
GitHub

parent
bb1b0d759e
commit
a4287b8586
@ -1,4 +1,4 @@
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
import jwt
|
||||
@ -22,7 +22,7 @@ def generate_jwt(
|
||||
) -> str:
|
||||
payload = data.copy()
|
||||
if lifetime_seconds:
|
||||
expire = datetime.utcnow() + timedelta(seconds=lifetime_seconds)
|
||||
expire = datetime.now(timezone.utc) + timedelta(seconds=lifetime_seconds)
|
||||
payload["exp"] = expire
|
||||
return jwt.encode(payload, _get_secret_value(secret), algorithm=algorithm)
|
||||
|
||||
|
Reference in New Issue
Block a user