feat(admin): 微信用户观测页 + 唯一昵称 + 密钥明文回显(单管理员后台)
按需求四项: 1. 微信新用户昵称改「微信用户_XXXXX」:后缀从 openid 的 sha1 派生(去混淆字母表), openid 唯一 → 后缀实际不重复,且同 openid 每次一致(重登不换名)。用户可自行改名。 2. 后台加「平台 → 微信用户」列表:昵称 / openid(点击复制)/ 积分余额 / 加入时间。 每人仍独立租户与积分(各买各的,确认过不共享积分池),此页只做统一观测。 3. 登录设置的 AppSecret 明文回显(不再只显示"已保存")。 4. 支付配置的 APIv3 密钥明文回显。 —— 用户明确后台单人使用、RequireAdmin 已拦,接受这一安全降级;密文仍加密入库。 修一个 gorm Scan 坑:WechatUserRow 的 WechatOpenID/BalanceMicro 没加 column tag, gorm 把 WechatOpenID 断成列名 wechat_open_id,与 SQL alias wechat_openid 对不上 → openid 静默返回空。教训:Scan 到自定义结构 + SQL 用 alias 时,字段一律显式加 column tag。 本地验证:真库造两个微信用户,列表接口正确返回 openid(修 tag 前是空); 登录设置页 AppSecret 已是可见文本框;nickname 单测覆盖唯一/稳定/去混淆。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -27,10 +27,9 @@ export function TopupChannels() {
|
||||
}
|
||||
|
||||
// ---- 微信支付配置:DB 存储、保存即热生效(不重启 gateway)。
|
||||
// APIv3 密钥只写不回显(密文入库,与模型 API Key 同一把密钥加密);
|
||||
// 商户证书私钥文件放服务器磁盘,这里只填路径。
|
||||
// APIv3 密钥密文入库,但单管理员后台明文回显方便核对;证书私钥文件放服务器磁盘,此处只填路径。
|
||||
function WechatConfigBlock() {
|
||||
const empty: WechatPayConfig = { mchid: "", cert_serial: "", private_key_path: "", public_key_path: "", public_key_id: "", appid: "", notify_url: "", has_apiv3_key: false };
|
||||
const empty: WechatPayConfig = { mchid: "", cert_serial: "", private_key_path: "", public_key_path: "", public_key_id: "", appid: "", notify_url: "", apiv3_key: "" };
|
||||
const [cfg, setCfg] = useState<WechatPayConfig>(empty);
|
||||
const [apiv3, setApiv3] = useState(""); // 留空=沿用已存
|
||||
const [enabled, setEnabled] = useState(false);
|
||||
@@ -42,6 +41,7 @@ function WechatConfigBlock() {
|
||||
getWechatPay()
|
||||
.then((r) => {
|
||||
setCfg(r.config);
|
||||
setApiv3(r.config.apiv3_key);
|
||||
setEnabled(r.enabled);
|
||||
setReason(r.reason);
|
||||
})
|
||||
@@ -65,8 +65,6 @@ function WechatConfigBlock() {
|
||||
});
|
||||
setEnabled(r.enabled);
|
||||
setReason(r.reason);
|
||||
setApiv3("");
|
||||
if (apiv3) setCfg((c) => ({ ...c, has_apiv3_key: true }));
|
||||
} catch (e) {
|
||||
setErr((e as Error).message);
|
||||
} finally {
|
||||
@@ -108,12 +106,11 @@ function WechatConfigBlock() {
|
||||
{field("公钥 ID(PUB_KEY_ID_ 开头)", "public_key_id", "PUB_KEY_ID_01…")}
|
||||
{field("微信支付公钥文件路径(服务器磁盘)", "public_key_path", "/etc/sundynix/wechat/pub_key.pem", "md:col-span-2")}
|
||||
<label className="text-xs text-gray-500">
|
||||
APIv3 密钥{cfg.has_apiv3_key && <span className="ml-1 text-emerald-600">已保存</span>}
|
||||
APIv3 密钥
|
||||
<input
|
||||
type="password"
|
||||
value={apiv3}
|
||||
onChange={(e) => setApiv3(e.target.value)}
|
||||
placeholder={cfg.has_apiv3_key ? "留空则沿用已保存的" : "32 字节"}
|
||||
placeholder="32 字节"
|
||||
className="mt-1 block w-full rounded-lg border border-gray-200 px-2.5 py-1.5 font-mono text-sm text-gray-800 focus:border-violet-400 focus:outline-none"
|
||||
/>
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user