fix: 学时读不到时先重新登录再判断凭据失效

This commit is contained in:
Nixevol
2026-11-21 15:28:59 +08:00
parent a5539405ca
commit d5226fc1a1
3 changed files with 60 additions and 3 deletions
+15
View File
@@ -180,6 +180,21 @@ def check_employee(db: Session, employee_id: str) -> dict:
try:
client.restore(credential)
found = describe_credential(client)
from euniv.client import is_qr_password
if not found["valid"] and password and not is_qr_password(password):
try:
from admin.settings import auto_attempt_count
from euniv.client import LoginRejected
from euniv.service import _persist
logged = client.login(manual=False, auto_attempts=auto_attempt_count(db))
_persist(db, employee_id, password, client, logged)
found = describe_credential(client)
except LoginRejected:
found = {"valid": False, "profile": {}, "hours": "", "official": ""}
except Exception:
pass
result = "有效" if found["valid"] else "已失效"
valid = bool(found["valid"])
profile = found["profile"]