forked from test2/Amnezia-Web-Panel-main
Fix naive/aware datetime comparison for user expiration.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1855,16 +1855,18 @@ async def periodic_background_tasks():
|
||||
if uid not in to_disable_uids:
|
||||
to_disable_uids.append(uid)
|
||||
|
||||
# Check expiration date
|
||||
exp_str = u.get('expiration_date')
|
||||
if exp_str and u.get('enabled', True):
|
||||
# Check expiration date (naive/aware-safe)
|
||||
if u.get('enabled', True):
|
||||
try:
|
||||
exp_date = datetime.fromisoformat(exp_str)
|
||||
if now > exp_date:
|
||||
logger.info(f"Subscription expired for user {u['username']} (expired at {exp_str})")
|
||||
from managers.user_expiration import user_is_expired
|
||||
if user_is_expired(u, now=now):
|
||||
logger.info(
|
||||
f"Subscription expired for user {u['username']} "
|
||||
f"(expired at {u.get('expiration_date')})"
|
||||
)
|
||||
if uid not in to_disable_uids:
|
||||
to_disable_uids.append(uid)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
save_data(curr_data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user