功能:禁用用户名管理(永久禁词列表)

数据库:
- 新增迁移 username_blacklist 表加 type/reason 列
  type: temp(改名30天保留)| permanent(管理员永久禁用)
  reason: 禁用原因备注(最长100字符)

核心逻辑:
- UsernameBlacklist::isBlocked() 同时拦截两种类型
  也包含 isReserved() 兼容旧调用
  增加 scopePermanent()/scopeTemp() 查询作用域
- AuthController 注册时加 isBlocked() 拦截
  禁词/保留期内均不可注册
- ShopService::useRenameCard() 已有 isReserved() 调用
  因已改用 isBlocked() 别名,无需修改

后台:
- ForbiddenUsernameController:index/store/update/destroy
- 路由:/admin/forbidden-usernames(chat.site_owner 中间件)
- 视图:admin/forbidden-usernames/index.blade.php
  新增表单、关键词搜索、分页、行内编辑原因、删除
- 侧边栏加「🚫 禁用用户名」入口(仅站长可见)
This commit is contained in:
2026-03-01 14:00:38 +08:00
parent 312b92a81d
commit fc495ccceb
7 changed files with 462 additions and 13 deletions

View File

@@ -0,0 +1,45 @@
<?php
/**
* 文件功能:为 username_blacklist 表新增 type reason 字段
*
* type 区分临时保留改名后30天与永久禁用管理员设置
* reason 记录永久禁用的原因(如:攻击性词汇、领导人名称等)
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 执行迁移:新增 type reason 列。
*/
public function up(): void
{
Schema::table('username_blacklist', function (Blueprint $table) {
// 类型temp = 改名后临时保留permanent = 管理员永久禁用
$table->enum('type', ['temp', 'permanent'])
->default('temp')
->after('username')
->comment('temp=改名临时保留 | permanent=管理员永久禁用词');
// 禁用原因permanent 时填写)
$table->string('reason', 100)
->nullable()
->after('reserved_until')
->comment('永久禁用原因(攻击性词汇、领导人名称等)');
});
}
/**
* 回滚:删除新增列。
*/
public function down(): void
{
Schema::table('username_blacklist', function (Blueprint $table) {
$table->dropColumn(['type', 'reason']);
});
}
};