修复: 防止管理员封禁自己的账号
- 在封禁用户API中添加自我封禁检查 - 当管理员尝试封禁自己时返回400错误 - 错误消息: "不能封禁自己的账号" - 解封自己不受限制(虽然被封禁后无法登录后台操作) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1911,6 +1911,14 @@ app.post('/api/admin/users/:id/ban', authMiddleware, adminMiddleware, (req, res)
|
||||
const { id } = req.params;
|
||||
const { banned } = req.body;
|
||||
|
||||
// 防止管理员封禁自己
|
||||
if (parseInt(id) === req.user.id && banned) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: '不能封禁自己的账号'
|
||||
});
|
||||
}
|
||||
|
||||
UserDB.setBanStatus(id, banned);
|
||||
|
||||
res.json({
|
||||
|
||||
Reference in New Issue
Block a user