完善首页邮箱找回密码流程
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:前台邮箱重置密码请求验证器
|
||||
*
|
||||
* 负责校验重置令牌、邮箱和新密码字段。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 类功能:校验邮箱重置密码表单提交的数据。
|
||||
*/
|
||||
class ResetPasswordRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 判断当前请求是否允许继续执行。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义重置密码请求的验证规则。
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'token' => ['required', 'string'],
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
'password' => ['required', 'string', 'min:6', 'confirmed'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义重置密码请求的中文错误提示。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'token.required' => '重置凭证缺失,请重新从邮件中的链接进入。',
|
||||
'email.required' => '邮箱不能为空。',
|
||||
'email.email' => '邮箱格式不正确。',
|
||||
'password.required' => '请输入新的登录密码。',
|
||||
'password.min' => '新密码长度至少需要 6 位。',
|
||||
'password.confirmed' => '两次输入的新密码不一致。',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:发送邮箱找回密码链接请求验证器
|
||||
*
|
||||
* 负责校验独立找回密码页面提交的邮箱字段。
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 类功能:校验邮箱找回密码所需的邮箱参数。
|
||||
*/
|
||||
class SendPasswordResetLinkRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 判断当前请求是否允许继续执行。
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义邮箱找回密码请求的验证规则。
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义邮箱找回密码请求的中文错误提示。
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'email.required' => '请输入已绑定账号的邮箱地址。',
|
||||
'email.email' => '邮箱格式不正确,请重新输入。',
|
||||
'email.max' => '邮箱长度不能超过 255 个字符。',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateProfileRequest extends FormRequest
|
||||
{
|
||||
@@ -33,7 +34,7 @@ class UpdateProfileRequest extends FormRequest
|
||||
'sex' => ['required', 'in:0,1,2'],
|
||||
'headface' => ['required', 'string', 'max:50'], // 比如存放 01.gif - 50.gif
|
||||
'sign' => ['nullable', 'string', 'max:255'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'email' => ['nullable', 'email', 'max:255', Rule::unique('users', 'email')->ignore($this->user()?->id)],
|
||||
'question' => ['nullable', 'string', 'max:100'],
|
||||
'answer' => ['nullable', 'string', 'max:100'],
|
||||
];
|
||||
@@ -44,6 +45,7 @@ class UpdateProfileRequest extends FormRequest
|
||||
return [
|
||||
'sex.in' => '性别选项无效(0=保密 1=男 2=女)。',
|
||||
'headface.required' => '必须选择一个头像。',
|
||||
'email.unique' => '该邮箱已被其他账号绑定,请更换一个邮箱。',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user