作者 F4NNIU

注册时防止昵称重复

... ... @@ -125,11 +125,15 @@ class Auth
*/
public function register($username, $password, $email = '', $mobile = '', $extend = [])
{
// 检测用户名邮箱、手机号是否存在
// 检测用户名、昵称、邮箱、手机号是否存在
if (User::getByUsername($username)) {
$this->setError('Username already exist');
return false;
}
if (User::getByNickname($username)) {
$this->setError('Nickname already exist');
return false;
}
if ($email && User::getByEmail($email)) {
$this->setError('Email already exist');
return false;
... ...
... ... @@ -29,6 +29,7 @@ return [
'Email is incorrect' => '邮箱格式不正确',
'Mobile is incorrect' => '手机格式不正确',
'Username already exist' => '用户名已经存在',
'Nickname already exist' => '昵称已经存在',
'Email already exist' => '邮箱已经存在',
'Mobile already exist' => '手机号已经存在',
'Username is incorrect' => '用户名不正确',
... ...