From 8fe0e729ea5d46531ad2650e17e8a2f9018ecc97 Mon Sep 17 00:00:00 2001 From: Nixevol Date: Mon, 16 Nov 2026 17:15:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B3=A8=E9=94=80=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E4=B8=8E=E5=87=AD=E8=AF=81=E5=88=B7=E6=96=B0=E5=85=B1?= =?UTF-8?q?=E7=94=A8=E5=90=8C=E4=B8=80=E6=8A=8A=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/admin/users.py | 11 ++++++----- backend/euniv/service.py | 16 +++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/backend/admin/users.py b/backend/admin/users.py index cd3176d..8003bd2 100644 --- a/backend/admin/users.py +++ b/backend/admin/users.py @@ -365,15 +365,16 @@ def set_study_settings( def delete_user(db: Session, employee_id: str) -> dict: - account = _require(db, employee_id) - db.delete(account) - db.commit() + from euniv.service import _credential_lock, release_credential_lock + + with _credential_lock(employee_id): + account = _require(db, employee_id) + 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) return {"ok": True} diff --git a/backend/euniv/service.py b/backend/euniv/service.py index f39dbbf..a6ddbbd 100644 --- a/backend/euniv/service.py +++ b/backend/euniv/service.py @@ -539,13 +539,15 @@ def _live(db: Session, employee_id: str, client_factory, read): def revoke_credential(db: Session, employee_id: str) -> None: - account = db.get(Account, employee_id) - if account is None: - return - account.credential_cipher = "" - account.password_cipher = "" - account.sessions_valid_after = datetime.now(timezone.utc) - db.commit() + with _credential_lock(employee_id): + account = db.get(Account, employee_id) + if account is None: + return + db.refresh(account) + account.credential_cipher = "" + account.password_cipher = "" + account.sessions_valid_after = datetime.now(timezone.utc) + db.commit() from euniv.autostudy import stop_account from euniv.study_push import close_account