From e1894c15b6abb2c49e49073fe9d5046d799cff81 Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 7 Nov 2025 08:36:31 +0000 Subject: [PATCH] fix(user): Ensure user reset removes usage fields correctly --- core/scripts/hysteria2/reset_user.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/core/scripts/hysteria2/reset_user.py b/core/scripts/hysteria2/reset_user.py index 91516af..5f6707f 100644 --- a/core/scripts/hysteria2/reset_user.py +++ b/core/scripts/hysteria2/reset_user.py @@ -2,8 +2,6 @@ import init_paths import sys -import os -from datetime import date from db.database import db def reset_user(username): @@ -26,15 +24,21 @@ def reset_user(username): print(f"Error: User '{username}' not found in the database.") return 1 - updates = { - 'upload_bytes': 0, - 'download_bytes': 0, - 'status': 'Offline', - 'account_creation_date': date.today().strftime("%Y-%m-%d"), - 'blocked': False - } + result = db.collection.update_one( + {'_id': username}, + { + '$set': { + 'status': 'On-hold', + 'blocked': False + }, + '$unset': { + 'account_creation_date': "", + 'download_bytes': "", + 'upload_bytes': "" + } + } + ) - result = db.update_user(username, updates) if result.modified_count > 0: print(f"User '{username}' has been reset successfully.") return 0