webman后台

This commit is contained in:
2026-03-07 19:42:22 +08:00
parent 9ed4c1bc58
commit 83725aef88
181 changed files with 19115 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace app\api\validate;
use think\Validate;
class Account extends Validate
{
protected $failException = true;
protected $rule = [
'username' => 'require|regex:^[a-zA-Z][a-zA-Z0-9_]{2,15}$|unique:user',
'nickname' => 'require|chsDash',
'birthday' => 'date',
'email' => 'require|email|unique:user',
'mobile' => 'require|mobile|unique:user',
'password' => 'require|regex:^(?!.*[&<>"\'\n\r]).{6,32}$',
'account' => 'require',
'captcha' => 'require',
];
protected $scene = [
'edit' => ['username', 'nickname', 'birthday'],
'changePassword' => ['password'],
'retrievePassword' => ['account', 'captcha', 'password'],
];
public function __construct()
{
$this->field = [
'username' => __('Username'),
'email' => __('Email'),
'mobile' => __('Mobile'),
'password' => __('Password'),
'nickname' => __('nickname'),
'birthday' => __('birthday'),
];
$this->message = array_merge($this->message, [
'nickname.chsDash' => __('nicknameChsDash'),
'password.regex' => __('Please input correct password')
]);
parent::__construct();
}
}

View File

@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace app\api\validate;
use think\Validate;
class User extends Validate
{
protected $failException = true;
protected $rule = [
'username' => 'require|regex:^[a-zA-Z][a-zA-Z0-9_]{2,15}$|unique:user',
'password' => 'require|regex:^(?!.*[&<>"\'\n\r]).{6,32}$',
'registerType' => 'require|in:email,mobile',
'email' => 'email|unique:user|requireIf:registerType,email',
'mobile' => 'mobile|unique:user|requireIf:registerType,mobile',
'captcha' => 'require',
'captchaId' => 'require',
'captchaInfo' => 'require',
];
protected $scene = [
'register' => ['username', 'password', 'registerType', 'email', 'mobile', 'captcha'],
];
public function sceneLogin(): static
{
$fields = ['username', 'password'];
$userLoginCaptchaSwitch = config('buildadmin.user_login_captcha');
if ($userLoginCaptchaSwitch) {
$fields[] = 'captchaId';
$fields[] = 'captchaInfo';
}
return $this->only($fields)->remove('username', ['regex', 'unique']);
}
public function __construct()
{
$this->field = [
'username' => __('Username'),
'email' => __('Email'),
'mobile' => __('Mobile'),
'password' => __('Password'),
'captcha' => __('captcha'),
'captchaId' => __('captchaId'),
'captchaInfo' => __('captcha'),
'registerType' => __('Register type'),
];
$this->message = array_merge($this->message, [
'username.regex' => __('Please input correct username'),
'password.regex' => __('Please input correct password')
]);
parent::__construct();
}
}