功能:禁用用户名管理(永久禁词列表)
数据库:
- 新增迁移 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:
@@ -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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user