fix: 检查凭据时同步姓名和公司
This commit is contained in:
@@ -1424,6 +1424,7 @@ class EunivClient:
|
||||
return response.text
|
||||
|
||||
def credential_alive(self) -> bool:
|
||||
self._checked_profile = None
|
||||
try:
|
||||
response = self._request("POST", f"{YXT_API}/v1/customdiy/user/getuserinfobyid", content=b"")
|
||||
except SessionExpired:
|
||||
@@ -1436,8 +1437,21 @@ class EunivClient:
|
||||
raise RuntimeError("学习平台暂时不可用") from exc
|
||||
if not isinstance(payload, dict):
|
||||
raise RuntimeError("学习平台暂时不可用")
|
||||
self._checked_profile = payload
|
||||
return bool(payload.get("cnName"))
|
||||
|
||||
def checked_profile(self) -> dict:
|
||||
"""最近一次凭据检查里的姓名和部门。职级不取出。"""
|
||||
payload = getattr(self, "_checked_profile", None)
|
||||
if not isinstance(payload, dict):
|
||||
return {}
|
||||
name = payload.get("cnName")
|
||||
company = payload.get("departmentName")
|
||||
return {
|
||||
"name": name if isinstance(name, str) else "",
|
||||
"department": company if isinstance(company, str) else "",
|
||||
}
|
||||
|
||||
def _pages(self, url: str, headers: dict, html: str, parse, identity: str) -> list[dict]:
|
||||
items = parse(html)
|
||||
seen = {(item.get("name", ""), item.get(identity, "")) for item in items}
|
||||
|
||||
@@ -478,7 +478,7 @@ def _profile_text(value: object, limit: int) -> str:
|
||||
|
||||
|
||||
def _remember_profile(db: Session, employee_id: str, payload: dict) -> None:
|
||||
"""首页已经取到姓名和部门时,顺手写回用户列表。不记录职级。"""
|
||||
"""首页或凭据检查已经取到姓名和部门时,顺手写回用户列表。不记录职级。"""
|
||||
if not isinstance(payload, dict):
|
||||
return
|
||||
name = _profile_text(payload.get("name"), 64)
|
||||
|
||||
Reference in New Issue
Block a user