Compare commits

..

No commits in common. "fdde49fb33cc4183fd54e5d6a1ee3af85730115d" and "6b01a13288167075c57969f39c358f99b62e0291" have entirely different histories.

6 changed files with 7 additions and 21 deletions

View File

@ -90,7 +90,7 @@ class User extends Api
//如果已经有账号则直接登录
$ret = $this->auth->direct($user->id);
} else {
$ret = $this->auth->register('', Random::alnum(16), '', $mobile, []);
$ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
$this->auth->getUser()->save(['verification' => ['email' => 0, 'mobile' => 1]]);
}
if ($ret) {
@ -132,9 +132,6 @@ class User extends Api
if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}
if (Validate::regex($username, '/^1\d{10}$/')) {
$this->error(__('Username can not be mobile'));
}
$ret = Sms::check($mobile, $code, 'register');
if (!$ret) {
$this->error(__('Captcha is incorrect'));

View File

@ -8,7 +8,6 @@ return [
'Username can not be empty' => '用户名不能为空',
'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
'Username can not be mobile' => '用户名不能使用手机号',
'Password can not be empty' => '密码不能为空',
'Password must be 6 to 30 characters' => '密码必须6-30个字符',
'Mobile is incorrect' => '手机格式不正确',

View File

@ -134,28 +134,22 @@ class Auth
* @param array $extend 扩展参数
* @return boolean
*/
public function register($username = '', $password = '', $email = '', $mobile = '', $extend = [])
public function register($username, $password, $email = '', $mobile = '', $extend = [])
{
//账号注册时需要开启事务,避免出现垃圾数据
Db::startTrans();
try {
$username = $username ?: Random::username();
$password = $password ?: Random::alnum(16);
$nickname = $extend['nickname'] ?? '用户' . mb_substr($mobile ?: strtoupper(Random::alnum(4)), -4);
// 检测用户名
if (User::checkExists('username', $username)) {
// 检测用户名、邮箱、手机号是否存在
if ($username && User::checkExists('username', $username)) {
$this->setError('Username already exist');
Db::rollback();
return false;
}
// 检测邮箱
if ($email && User::checkExists('email', $email)) {
$this->setError('Email already exist');
Db::rollback();
return false;
}
// 检测手机号
if ($mobile && User::checkExists('mobile', $mobile)) {
$this->setError('Mobile already exist');
Db::rollback();
@ -175,7 +169,7 @@ class Auth
'avatar' => '',
];
$params = array_merge($data, [
'nickname' => $nickname,
'nickname' => preg_match("/^1[3-9]{1}\d{9}$/", $username) ? substr_replace($username, '****', 3, 4) : $username,
'salt' => Random::alnum(),
'jointime' => $time,
'joinip' => $ip,

View File

@ -96,9 +96,6 @@ class User extends Frontend
'email' => 'Email is incorrect',
'mobile' => 'Mobile is incorrect',
];
if (Validate::regex($username, '/^1\d{10}$/')) {
$this->error(__('Username can not be mobile'));
}
$data = [
'username' => $username,
'password' => $password,

View File

@ -28,7 +28,6 @@ return [
'Username can not be empty' => '用户名不能为空',
'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
'Username can not be mobile' => '用户名不能使用手机号',
'Account must be 3 to 50 characters' => '账户必须3-50个字符',
'Password can not be empty' => '密码不能为空',
'Password must be 6 to 30 characters' => '密码必须6-30个字符',

View File

@ -279,7 +279,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
var nums = value === '' ? 0 : value.split(/\,/).length;
var files = data.url !== "" ? data.url.split(/\,/) : [];
$.each(files, function (i, j) {
var url = Config.upload.fullmode ? Fast.api.cdnurl(j, true) : j;
var url = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
urlArr.push(url);
});
if (maxcount > 0) {
@ -292,7 +292,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
var result = urlArr.join(",");
inputObj.val(result).trigger("change").trigger("validate");
} else if (input_id) {
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url, true) : data.url;
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
$("#" + input_id).val(url).trigger("change").trigger("validate");
}