From c38a53fa74136dc3c6dc98204c5a348ab8ef4e33 Mon Sep 17 00:00:00 2001 From: lkddi Date: Thu, 26 Feb 2026 22:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=80=A7=E5=88=AB=20+=20=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E5=AE=A4=E4=B8=AA=E4=BA=BA=E8=AE=BE=E7=BD=AE=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 登录表单的性别选择(bSex)在注册时保存到数据库(男/女/保密) - 新增 question/answer 密保字段迁移(hasColumn 安全检查) - User 模型 fillable 增加 sign/question/answer - UpdateProfileRequest 增加 email/question/answer 验证 - 聊天室工具栏新增设置按钮 - 设置弹窗包含:修改密码、性别、邮箱、密保问题 --- app/Http/Controllers/AuthController.php | 6 +- app/Http/Requests/LoginRequest.php | 1 + app/Http/Requests/UpdateProfileRequest.php | 3 + app/Models/User.php | 3 + ...26_144806_add_question_answer_to_users.php | 49 ++++++ resources/views/chat/frame.blade.php | 162 ++++++++++++++++++ .../views/chat/partials/toolbar.blade.php | 2 + 7 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2026_02_26_144806_add_question_answer_to_users.php diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 3a81057..0e561ba 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -63,13 +63,17 @@ class AuthController extends Controller // --- 核心:第一次登录即为注册 --- + // 映射性别:1=男 2=女,默认保密 + $sexMap = ['1' => '男', '2' => '女']; + $sex = $sexMap[$request->input('bSex', '')] ?? '保密'; + $newUser = User::create([ 'username' => $username, 'password' => Hash::make($password), 'first_ip' => $ip, 'last_ip' => $ip, 'user_level' => 1, // 默认普通用户等级 - 'sex' => 0, // 默认性别: 0保密 1男 2女 + 'sex' => $sex, 'usersf' => '1.GIF', // 默认头像 ]); diff --git a/app/Http/Requests/LoginRequest.php b/app/Http/Requests/LoginRequest.php index 462b9df..fb4782a 100644 --- a/app/Http/Requests/LoginRequest.php +++ b/app/Http/Requests/LoginRequest.php @@ -39,6 +39,7 @@ class LoginRequest extends FormRequest 'regex:/^[^<>\'"]+$/u', ], 'password' => ['required', 'string', 'min:1'], + 'bSex' => ['nullable', 'in:1,2'], 'captcha' => ['required', 'captcha'], ]; } diff --git a/app/Http/Requests/UpdateProfileRequest.php b/app/Http/Requests/UpdateProfileRequest.php index 84f715d..0aa734b 100644 --- a/app/Http/Requests/UpdateProfileRequest.php +++ b/app/Http/Requests/UpdateProfileRequest.php @@ -33,6 +33,9 @@ class UpdateProfileRequest extends FormRequest 'sex' => ['required', 'string', 'in:男,女,保密'], 'headface' => ['required', 'string', 'max:50'], // 比如存放 01.gif - 50.gif 'sign' => ['nullable', 'string', 'max:255'], + 'email' => ['nullable', 'email', 'max:255'], + 'question' => ['nullable', 'string', 'max:100'], + 'answer' => ['nullable', 'string', 'max:100'], ]; } diff --git a/app/Models/User.php b/app/Models/User.php index b56920b..bfd3a70 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -32,6 +32,7 @@ class User extends Authenticatable 'password', 'email', 'sex', + 'sign', 'user_level', 'room_id', 'first_ip', @@ -39,6 +40,8 @@ class User extends Authenticatable 'usersf', 'vip_level_id', 'hy_time', + 'question', + 'answer', ]; /** diff --git a/database/migrations/2026_02_26_144806_add_question_answer_to_users.php b/database/migrations/2026_02_26_144806_add_question_answer_to_users.php new file mode 100644 index 0000000..d83e8d0 --- /dev/null +++ b/database/migrations/2026_02_26_144806_add_question_answer_to_users.php @@ -0,0 +1,49 @@ +string('question', 100)->nullable()->after('email')->comment('密保问题'); + } + if (! Schema::hasColumn('users', 'answer')) { + $table->string('answer', 100)->nullable()->after('question')->comment('密保答案'); + } + }); + } + + /** + * 回滚:删除密保字段 + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $columns = []; + if (Schema::hasColumn('users', 'question')) { + $columns[] = 'question'; + } + if (Schema::hasColumn('users', 'answer')) { + $columns[] = 'answer'; + } + if ($columns) { + $table->dropColumn($columns); + } + }); + } +}; diff --git a/resources/views/chat/frame.blade.php b/resources/views/chat/frame.blade.php index c7659b1..e1c7a2d 100644 --- a/resources/views/chat/frame.blade.php +++ b/resources/views/chat/frame.blade.php @@ -404,6 +404,168 @@ + {{-- ═══════════ 个人设置弹窗 ═══════════ --}} + + + + diff --git a/resources/views/chat/partials/toolbar.blade.php b/resources/views/chat/partials/toolbar.blade.php index 4ba0fec..52bce15 100644 --- a/resources/views/chat/partials/toolbar.blade.php +++ b/resources/views/chat/partials/toolbar.blade.php @@ -22,6 +22,8 @@
呼叫
头像
+
设置 +
提议