57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?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' => '两次输入的新密码不一致。',
|
|
];
|
|
}
|
|
}
|