fix: 注销后关掉学习连接,目标为零不再显示成零比零

This commit is contained in:
2026-11-16 15:57:23 +08:00
parent 1cd7c7f818
commit 58b3dedb2a
8 changed files with 97 additions and 16 deletions
+7 -1
View File
@@ -8,6 +8,7 @@ from __future__ import annotations
import hmac
import threading
from contextlib import contextmanager
from admin.passwords import is_hashed, verify_password
from euniv.crypto import decrypt_secret
@@ -17,7 +18,12 @@ class AdminIdentity:
def __init__(self) -> None:
self._username = ""
self._password_cipher = ""
self._lock = threading.Lock()
self._lock = threading.RLock()
@contextmanager
def exclusive(self):
with self._lock:
yield
def replace(self, username: str, password_cipher: str) -> None:
with self._lock:
+3 -2
View File
@@ -260,8 +260,9 @@ def save_settings(db: Session, payload: dict) -> SystemConfig:
row.admin_password_cipher = hash_password(password_text)
if previous_username != username or password_text:
row.admin_sessions_valid_after = datetime.now(timezone.utc)
db.commit()
identity.replace(row.admin_username, row.admin_password_cipher)
with identity.exclusive():
db.commit()
identity.replace(row.admin_username, row.admin_password_cipher)
if interval != previous_interval:
from euniv.service import notify_refresh_interval_changed
+2
View File
@@ -316,8 +316,10 @@ def delete_user(db: Session, employee_id: str) -> dict:
db.delete(account)
db.commit()
from euniv.autostudy import stop_account
from euniv.study_push import close_account
stop_account(employee_id)
close_account(employee_id)
from euniv.service import release_credential_lock
release_credential_lock(employee_id)