fix: handle int type for JWT expires configuration to prevent 500 error on login
This commit is contained in:
@ -27,8 +27,11 @@ def _store_token_to_redis(user_id, token, token_type='access'):
|
|||||||
else:
|
else:
|
||||||
expires_delta = current_app.config.get('JWT_REFRESH_TOKEN_EXPIRES', timedelta(days=7))
|
expires_delta = current_app.config.get('JWT_REFRESH_TOKEN_EXPIRES', timedelta(days=7))
|
||||||
|
|
||||||
# 转换为秒数
|
# 转换为秒数(兼容 timedelta 和 int 类型)
|
||||||
|
if isinstance(expires_delta, timedelta):
|
||||||
expires_seconds = int(expires_delta.total_seconds())
|
expires_seconds = int(expires_delta.total_seconds())
|
||||||
|
else:
|
||||||
|
expires_seconds = int(expires_delta) # 已经是秒数(整数)
|
||||||
|
|
||||||
# 存储到 Redis
|
# 存储到 Redis
|
||||||
key = f"user_token_{user_id}"
|
key = f"user_token_{user_id}"
|
||||||
|
|||||||
Reference in New Issue
Block a user