回复框去掉管理员口令与处理状态;带 token 时昵称/邮箱锁定为只读
用户三个问题,本质是同一件事:token 就是身份凭证,那就不该再让表单声明身份。
一、去掉管理员口令 / 处理状态
用户:「回复这个地方,下面有个管理员口令,还有处理状态,都不要填了,
只保留回复内容,加上人机验证就可以了」
- 删掉表单里这两块,删掉 admin-pw/admin-status 的 CSS 与 bindAdminToggle 的 JS
- 管理员身份只认后台登录态(fb_is_admin()),不再从公开表单收口令
- 状态流转只在后台详情页那排按钮里做
二、带 token 时昵称/邮箱锁定为只读
用户:「如果他带着 Token 进来之后邮箱又让他改了,我们又没办法知道谁是谁了」
- 有 token = 已证明是提交人本人,表单不再让填昵称/邮箱,
改为显示只读的「回复身份」块(原昵称 + 原邮箱)
三、服务端强制(关键)
🔴 前端设成 hidden 是不够的 —— hidden 可以被改:
谁拿到链接、改个 email 提交,这条反馈的联系人就变成他的了。
所以服务端在 isOwnerView 时**直接丢弃 POST 里的 name/email**,
一律以库里那条帖子的 author_name / author_email 为准。
身份校验必须在服务端做。
验证(这次确保请求真的通过人机验证,不是被验证码挡住造成的假通过):
题目「2 乘以 7」答 14 → 跳转到 #r3,回复确实入库;
提交的是 黑客改名 / attacker@evil.example,
实际入库 name=jervis email=zeussun@msn.com —— 伪造的两个字段都被丢弃。
另外:无 token 的普通访客仍可自由填昵称邮箱;全站已无「管理员口令」残留。
测试回复已清理,reply_count 已同步。
This commit is contained in:
+3
-24
@@ -61,29 +61,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 管理员口令:填写后显示"处理状态",并解除邮箱必填 ---------- */
|
||||
function bindAdminToggle() {
|
||||
var pw = document.querySelector('input[name=admin_password]');
|
||||
if (!pw) { return; }
|
||||
var statusBox = document.querySelector('.admin-status');
|
||||
var emailInput = document.querySelector('input[name=email]');
|
||||
var emailField = document.getElementById('emailField');
|
||||
|
||||
function sync() {
|
||||
var isAdmin = pw.value.trim() !== '';
|
||||
if (statusBox) { statusBox.hidden = !isAdmin; }
|
||||
if (emailInput) {
|
||||
emailInput.required = !isAdmin;
|
||||
if (isAdmin) { emailInput.removeAttribute('required'); }
|
||||
}
|
||||
if (emailField) {
|
||||
var req = emailField.querySelector('.req');
|
||||
if (req) { req.style.visibility = isAdmin ? 'hidden' : 'visible'; }
|
||||
}
|
||||
}
|
||||
pw.addEventListener('input', sync);
|
||||
sync();
|
||||
}
|
||||
/* ---------- (已删)管理员口令切换 ----------
|
||||
* 回复表单里不再有「管理员口令」和「处理状态」——用户 2026-11-03 要求去掉。
|
||||
* 管理员身份改由后台登录态判断,状态流转在后台详情页的按钮里做。 */
|
||||
|
||||
/* ---------- 防止重复提交(上传未完成时阻止提交) ---------- */
|
||||
function bindNoDoubleSubmit() {
|
||||
@@ -884,7 +864,6 @@
|
||||
|
||||
function boot() {
|
||||
bindCaptchaRefresh();
|
||||
bindAdminToggle();
|
||||
bindWontfixPanel();
|
||||
bindColorPicker();
|
||||
bindIconPicker();
|
||||
|
||||
+14
-1
@@ -455,6 +455,20 @@ main.wrap{padding-top:24px; padding-bottom:40px; min-height:60vh}
|
||||
.item-meta{display:flex; flex-wrap:wrap; align-items:center; gap:6px; font-size:13px; color:var(--muted)}
|
||||
.item-meta .who{color:#3a424d; font-weight:600}
|
||||
|
||||
/* 带 token 回复时展示只读身份(昵称 + 邮箱) */
|
||||
.reply-identity{
|
||||
display:flex; align-items:center; flex-wrap:wrap; gap:8px;
|
||||
padding:9px 12px; border-radius:9px;
|
||||
background:var(--bg, #f6f8fb); border:1px solid var(--line);
|
||||
font-size:14px;
|
||||
}
|
||||
.reply-identity-nm{font-weight:600; color:var(--fg)}
|
||||
.reply-identity-mail{
|
||||
color:var(--muted); font-size:13px;
|
||||
padding:1px 8px; border-radius:99px; background:var(--card);
|
||||
border:1px solid var(--line);
|
||||
}
|
||||
|
||||
/* 提交人凭 token 看自己未公开反馈时的提示条 */
|
||||
.owner-note{
|
||||
display:flex; flex-direction:column; gap:4px;
|
||||
@@ -596,7 +610,6 @@ main.wrap{padding-top:24px; padding-bottom:40px; min-height:60vh}
|
||||
|
||||
.form-actions{margin-top:20px}
|
||||
.form-actions .btn{padding:10px 26px; font-size:15px}
|
||||
.admin-pw{margin-top:6px}
|
||||
.admin-status{margin-bottom:16px}
|
||||
|
||||
/* 蜜罐字段:对用户不可见,但保留在 DOM 中诱捕机器人 */
|
||||
|
||||
Reference in New Issue
Block a user