fix: 注销和删除与凭证刷新共用同一把锁
This commit is contained in:
@@ -365,15 +365,16 @@ def set_study_settings(
|
|||||||
|
|
||||||
|
|
||||||
def delete_user(db: Session, employee_id: str) -> dict:
|
def delete_user(db: Session, employee_id: str) -> dict:
|
||||||
account = _require(db, employee_id)
|
from euniv.service import _credential_lock, release_credential_lock
|
||||||
db.delete(account)
|
|
||||||
db.commit()
|
with _credential_lock(employee_id):
|
||||||
|
account = _require(db, employee_id)
|
||||||
|
db.delete(account)
|
||||||
|
db.commit()
|
||||||
from euniv.autostudy import stop_account
|
from euniv.autostudy import stop_account
|
||||||
from euniv.study_push import close_account
|
from euniv.study_push import close_account
|
||||||
|
|
||||||
stop_account(employee_id)
|
stop_account(employee_id)
|
||||||
close_account(employee_id)
|
close_account(employee_id)
|
||||||
from euniv.service import release_credential_lock
|
|
||||||
|
|
||||||
release_credential_lock(employee_id)
|
release_credential_lock(employee_id)
|
||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
|
|||||||
@@ -539,13 +539,15 @@ def _live(db: Session, employee_id: str, client_factory, read):
|
|||||||
|
|
||||||
|
|
||||||
def revoke_credential(db: Session, employee_id: str) -> None:
|
def revoke_credential(db: Session, employee_id: str) -> None:
|
||||||
account = db.get(Account, employee_id)
|
with _credential_lock(employee_id):
|
||||||
if account is None:
|
account = db.get(Account, employee_id)
|
||||||
return
|
if account is None:
|
||||||
account.credential_cipher = ""
|
return
|
||||||
account.password_cipher = ""
|
db.refresh(account)
|
||||||
account.sessions_valid_after = datetime.now(timezone.utc)
|
account.credential_cipher = ""
|
||||||
db.commit()
|
account.password_cipher = ""
|
||||||
|
account.sessions_valid_after = datetime.now(timezone.utc)
|
||||||
|
db.commit()
|
||||||
from euniv.autostudy import stop_account
|
from euniv.autostudy import stop_account
|
||||||
from euniv.study_push import close_account
|
from euniv.study_push import close_account
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user