|
@@ -200,6 +200,11 @@ class User extends Api
|
|
$user->username = $username;
|
|
$user->username = $username;
|
|
}
|
|
}
|
|
if ($nickname) {
|
|
if ($nickname) {
|
|
|
|
+ //限制长度
|
|
|
|
+ $nicknameLen = mb_strlen($nickname);
|
|
|
|
+ if ($nicknameLen > 12) {
|
|
|
|
+ $this->error('昵称不能超过12个字');
|
|
|
|
+ }
|
|
$exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
|
|
$exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
|
|
if ($exists) {
|
|
if ($exists) {
|
|
$this->error(__('Nickname already exist'));
|
|
$this->error(__('Nickname already exist'));
|
|
@@ -207,6 +212,11 @@ class User extends Api
|
|
$user->nickname = $nickname;
|
|
$user->nickname = $nickname;
|
|
}
|
|
}
|
|
if ($mobile) {
|
|
if ($mobile) {
|
|
|
|
+ //验证手机号
|
|
|
|
+ $isMobile = is_mobile($mobile);
|
|
|
|
+ if (!$isMobile) {
|
|
|
|
+ $this->error('手机号格式错误');
|
|
|
|
+ }
|
|
$exists = \app\common\model\User::where('mobile', $mobile)->where('id', '<>', $this->auth->id)->find();
|
|
$exists = \app\common\model\User::where('mobile', $mobile)->where('id', '<>', $this->auth->id)->find();
|
|
if ($exists) {
|
|
if ($exists) {
|
|
$this->error(__('Mobile already exist'));
|
|
$this->error(__('Mobile already exist'));
|