fix: 学时读不到时先重新登录再判断凭据失效
This commit is contained in:
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user