feat: 退出时选择离开系统或删除账号

This commit is contained in:
Nixevol
2026-11-18 10:16:29 +08:00
parent bb23521e9b
commit 3670a76dfe
4 changed files with 88 additions and 40 deletions
+9 -8
View File
@@ -10,7 +10,7 @@ import time
from datetime import datetime, timedelta, timezone
from dataclasses import dataclass
from sqlalchemy import select
from sqlalchemy import delete, select
from sqlalchemy.orm import Session
from euniv.client import (
@@ -580,15 +580,16 @@ def _live(db: Session, employee_id: str, client_factory, read):
def revoke_credential(db: Session, employee_id: str) -> None:
"""从本平台删除账号,并停掉定时任务和已经开始的学习。"""
from euniv.models import FinishedCourse
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()
if account is not None:
db.refresh(account)
db.execute(delete(FinishedCourse).where(FinishedCourse.employee_id == employee_id))
db.delete(account)
db.commit()
from euniv.autostudy import stop_account
from euniv.study_push import close_account