mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-15 03:04:27 +08:00
Close #3: forgot/reset password routes
This commit is contained in:
14
fastapi_users/utils.py
Normal file
14
fastapi_users/utils.py
Normal file
@ -0,0 +1,14 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import jwt
|
||||
|
||||
JWT_ALGORITHM = "HS256"
|
||||
|
||||
|
||||
def generate_jwt(
|
||||
data: dict, lifetime_seconds: int, secret: str, algorithm: str = JWT_ALGORITHM
|
||||
) -> str:
|
||||
payload = data.copy()
|
||||
expire = datetime.utcnow() + timedelta(seconds=lifetime_seconds)
|
||||
payload["exp"] = expire
|
||||
return jwt.encode(payload, secret, algorithm=algorithm).decode("utf-8")
|
Reference in New Issue
Block a user