chore: 版本升级至1.1.8,新增钉钉账号通知等功能

1. 版本号更新:shell.version与install.iss同步升级到1.1.8
2. 新增钉钉账号创建通知:新用户收账号密码,管理员收权限提醒
3. 优化钉钉扫码登录逻辑:自动补全账号信息并同步昵称
4. 修复首次改密校验逻辑,统一初始密码验证规则
5. 新增AGENTS文档写入操作沙箱规避规范
6. 优化雇主险调度脚本,新增四级部门自动填充逻辑
7. 重构前端更新弹窗,将下载进度从顶部条改为独立弹窗
8. 新增EHR考勤异常检查脚本,优化打卡判定逻辑
This commit is contained in:
2026-09-18 21:25:43 +08:00
parent 78aa8c361c
commit 11fc3cee6a
14 changed files with 1134 additions and 598 deletions
+3
View File
@@ -17,6 +17,7 @@ from controlplane import config, schemas
from controlplane.core.auth import _require_admin, _resolve_login
from controlplane.core.crypto import _hash_password
from controlplane.core.db import _audit, _db, _now
from controlplane.core.notify import notify_account_created
from controlplane.core.pkgutil import (
_SAFE_NAME_RE, _extract_manifest, _load_manifest, _prune_versions,
_validate_pkg_zip, _version_key,
@@ -67,6 +68,8 @@ def admin_account_create(a: schemas.AccountCreateIn,
(account, _hex, _salt, int(a.is_admin), (a.dept or "").strip(),
(a.nickname or "").strip(), _now()))
conn.commit()
# 钉钉工作通知(异步,失败不阻断建号):新用户收账号密码(按昵称解析),管理员收权限开通提醒
notify_account_created(account, (a.nickname or "").strip(), a.password, source="管理台")
return {"ok": True, "account": account, "dept": (a.dept or "").strip(),
"nickname": (a.nickname or "").strip(), "is_admin": a.is_admin}
+38 -13
View File
@@ -10,12 +10,13 @@ from fastapi import APIRouter, Header, HTTPException
from controlplane import config, schemas
from controlplane.core.auth import (
_AUTH_FAILS, _auth_account_lookup, _auth_fail, _auth_gate, _check_token,
_AUTH_FAILS, _auth_fail, _auth_gate, _check_token,
_cloud_account, _issue_cloud_token, _resolve_login, _require_admin, _sign_admin_token,
)
from controlplane.core.crypto import _hash_password, _verify_password
from controlplane.core.db import _db
from controlplane.core.dingtalk import _dingtalk_userinfo
from controlplane.core.notify import notify_account_created
router = APIRouter()
@@ -117,9 +118,8 @@ def admin_password(p: schemas.PwdIn,
(login,)).fetchone()
if not row:
raise HTTPException(401, "账号不存在")
# 首次登录(must_change_pwd=1,钉钉自动建号的默认密码)允许免旧密码直接改密
if not row["must_change_pwd"] and (
not row["salt"] or not _verify_password(p.old_password, row["salt"], row["password_hash"])):
# 旧密码校验(所有账号均带盐;首次改密的旧密码 = 钉钉通知下发的初始密码,同样必须输入)
if not row["salt"] or not _verify_password(p.old_password, row["salt"], row["password_hash"]):
raise HTTPException(401, "原密码错误")
_hex, _salt = _hash_password(p.new_password)
with _db() as conn:
@@ -130,14 +130,15 @@ def admin_password(p: schemas.PwdIn,
# ==================== 员工端登录 /auth/exchange(v3 最简方案,壳本机直连接 code) ====================
# 壳 login 云端的唯一接口:壳把浏览器带回的钉钉 code POST 到此,用 AppSecret 换身份 → 只验证不建号
# → 签发云端会话 token(供壳调 /api/plugins 鉴权,见 apis/plugins §2.2)。token 存储统一在
# core.auth(_issue_cloud_token 签发落库 cloud_tokens 表、_cloud_account 解析),此处不再重复声明。
# 壳 login 云端的唯一接口:壳把浏览器带回的钉钉 code POST 到此,用 AppSecret 换身份 → 找建账号
# (不存在则自动建号:空壳+默认密码+强制改密,并推送钉钉通知)→ 签发云端会话 token(供壳调
# /api/plugins 鉴权,见 apis/plugins §2.2)。token 存储统一在 core.auth(_issue_cloud_token 签发
# 落库 cloud_tokens 表、_cloud_account 解析),此处不再重复声明。
@router.post("/auth/exchange")
def auth_exchange(d: schemas.AuthExchangeIn) -> dict:
"""壳 → 云端:壳 POST 钉钉授权码 code,换取员工工号 + 云端会话 token(只验证不建号)。"""
"""壳 → 云端:壳 POST 钉钉授权码 code,换取员工工号 + 云端会话 token(找建账号)。"""
code = (d.code or "").strip()
if not code:
raise HTTPException(400, "缺少 code")
@@ -147,9 +148,33 @@ def auth_exchange(d: schemas.AuthExchangeIn) -> dict:
account = (info.get("account") or "").strip()
if not account:
raise HTTPException(401, "扫码未解析到有效账号,请重新扫码")
acct = _auth_account_lookup(account)
nickname = acct["nickname"] or (info.get("nickname") or "")
nickname = (info.get("nickname") or "").strip()
unionid = (info.get("unionid") or "").strip()
# 找建账号(与 /api/admin/dingtalk/auth 同语义):已存在则同步昵称;不存在则自动建号并通知
with _db() as conn:
row = conn.execute(
"SELECT nickname, status, must_change_pwd FROM accounts WHERE account = %s",
(account,)).fetchone()
if row:
if not row["status"]:
raise HTTPException(403, "账号已停用,请联系管理员")
if nickname and nickname != (row["nickname"] or ""):
conn.execute("UPDATE accounts SET nickname = %s WHERE account = %s",
(nickname, account))
conn.commit()
created, must_change = False, bool(row["must_change_pwd"])
else:
# 自动建号(空壳):初始密码取默认值,强制首次改密
pwd = config.DINGTALK_DEFAULT_PASSWORD
_hex, _salt = _hash_password(pwd)
conn.execute(
"INSERT INTO accounts(account, password_hash, salt, is_admin, dept, nickname, "
"dingtalk_uid, must_change_pwd) VALUES (%s, %s, %s, 0, '', %s, %s, 1)",
(account, _hex, _salt, nickname, unionid))
conn.commit()
created, must_change = True, True
notify_account_created(account, nickname, pwd, unionid, source="钉钉扫码")
token = _issue_cloud_token(account, nickname)
return {"token": token,
"account": account, "nickname": nickname,
"exists": bool(acct["exists"]), "is_admin": False}
return {"token": token, "account": account, "nickname": nickname,
"exists": True, "created": created, "must_change_pwd": must_change,
"is_admin": False}
+3
View File
@@ -18,6 +18,7 @@ from controlplane.core.auth import _check_token, _sign_admin_token
from controlplane.core.crypto import _hash_password
from controlplane.core.db import _db
from controlplane.core.dingtalk import _dingtalk_sns_userinfo, _dingtalk_userinfo
from controlplane.core.notify import notify_account_created
router = APIRouter()
@@ -63,6 +64,8 @@ def admin_dingtalk_auth(d: schemas.DingTalkIn,
"dingtalk_uid, must_change_pwd) VALUES (%s, %s, %s, 0, '', %s, %s, 1)",
(account, _hex, _salt, nickname, ding_uid))
conn.commit()
# 钉钉工作通知(异步,失败不阻断建号):新用户收默认账号密码,管理员收权限开通提醒
notify_account_created(account, nickname, pwd, ding_uid, source="钉钉扫码")
return {"ok": True, "account": account, "nickname": nickname,
"is_admin": False, "created": True, "must_change_pwd": True,
"token": _sign_admin_token(account)}