添加授权依赖
This commit is contained in:
@@ -94,7 +94,13 @@ class JwtAuthMiddleware(BaseHTTPMiddleware):
|
||||
now = datetime.now(timezone.utc)
|
||||
valid_devices = []
|
||||
for d in devices:
|
||||
last_login = datetime.fromisoformat(d["lastLoginTime"])
|
||||
last_login_str = d["lastLoginTime"]
|
||||
# 兼容 Java Instant 格式(尾部 Z)
|
||||
if last_login_str.endswith("Z"):
|
||||
last_login_str = last_login_str[:-1] + "+00:00"
|
||||
last_login = datetime.fromisoformat(last_login_str)
|
||||
if last_login.tzinfo is None:
|
||||
last_login = last_login.replace(tzinfo=timezone.utc)
|
||||
if (now - last_login).total_seconds() < settings.token_expire_seconds:
|
||||
valid_devices.append(d)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user