From 29e4b4e5012f54fb932dd2039168ae088748036f Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Mon, 30 Sep 2019 20:52:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/UserController.class.php | 9 ++++++++- Application/User/Model/UcenterMemberModel.class.php | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php index 79ced5041..b9b8ff816 100644 --- a/Application/Admin/Controller/UserController.class.php +++ b/Application/Admin/Controller/UserController.class.php @@ -250,7 +250,14 @@ class UserController extends AdminController { if($password != $repassword){ $this->error('管理员密码和确认密码不一致!'); } - + $usernameUser = M('UcenterMember', 'sys_')->field('username')->where(['username' => $username])->find(); + if (!empty($usernameUser)) { + $this->error('用户名已存在!'); + } + $emailUser = M('UcenterMember', 'sys_')->field('username')->where(['username' => $username])->find(); + if (!empty($emailUser)) { + $this->error('邮箱已存在!'); + } /* 调用注册接口注册用户 */ $User = new UserApi; $uid = $User->register($username, $password, $email,$second_pwd); diff --git a/Application/User/Model/UcenterMemberModel.class.php b/Application/User/Model/UcenterMemberModel.class.php index 6f927f44b..0ff123746 100644 --- a/Application/User/Model/UcenterMemberModel.class.php +++ b/Application/User/Model/UcenterMemberModel.class.php @@ -102,7 +102,7 @@ class UcenterMemberModel extends Model{ * @param string $mobile 用户手机号码 * @return integer 注册成功-用户信息,注册失败-错误编号 */ - public function register($username, $password, $email,$second_pwd,$mobile){ + public function register($username, $password, $email, $second_pwd,$mobile){ $data = array( 'username' => $username, 'password' => $password, @@ -110,11 +110,13 @@ class UcenterMemberModel extends Model{ 'email' => $email, 'mobile' => $mobile, ); - + //验证手机 if(empty($data['mobile'])) unset($data['mobile']); /* 添加用户 */ if($data = $this->create($data)){ + $data['username'] = $username; + $data['email'] = $email; $status = M('UcenterMember', 'sys_')->data($data)->add(); $uid = 0; if ($status) {