From 288f1219551c39ca5100ec7fbf3e0fd6eb83affd Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 13 Jul 2020 10:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=8B=E6=9C=BA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PublicController.class.php | 35 ++++++++++++++++- .../Admin/Controller/UserController.class.php | 39 +++++++++++-------- Application/Admin/View/User/add.html | 7 ++++ Application/Admin/View/User/edit.html | 10 +++++ .../User/Model/UcenterMemberModel.class.php | 4 +- 5 files changed, 76 insertions(+), 19 deletions(-) diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index de9ec0347..1239ee8ab 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -81,7 +81,7 @@ class PublicController extends \Think\Controller $this->error('验证码错误'); } $member = M('ucenter_member ucenter') - ->field("uid,nickname,last_login_time,status") + ->field("uid,nickname,ucenter.last_login_time,member.status") ->join("left join sys_member member on ucenter.id=member.uid") ->where(['mobile' => $mobile])->find(); @@ -94,8 +94,39 @@ class PublicController extends \Think\Controller if ($member) { /* 记录登录SESSION和COOKIES */ $Member = D('Member'); - $Member->autoLogin($member); + /* 更新登录信息 */ + $data = array( + 'uid' => $member['uid'], + 'login' => array('exp', '`login`+1'), + 'last_login_time' => NOW_TIME, + 'last_login_ip' => get_client_ip(1), + ); + $Member->save($data); + + $adminData = getAdminData($member['uid']); + $groupId = getGameGroup($member['uid']); + + /* 记录登录SESSION和COOKIES */ + $auth = array( + 'uid' => $member['uid'], + 'username' => $member['nickname'], + 'last_login_time' => $member['last_login_time'], + 'data_empower_type'=>$adminData['data_empower_type'], + 'data_president'=>$adminData['data_president'], + 'show_data'=>$adminData['show_data'], + ); + //登录有效时间改为6小时 + $expireTime = 3600; + ini_set('session.gc_maxlifetime', $expireTime); + ini_set('session.cookie_lifetime', $expireTime); + session('user_group_id',$groupId); + session('user_auth', $auth); + session('user_auth_sign', data_auth_sign($auth)); + session('user_auth_expire', time()); + session_regenerate_id(); + } else { + $this->error('登录失败'); } // else { // $partner = M('partner', 'tab_')->where(['link_phone' => $mobile,])->find(); diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php index 98eb44392..b746bcf91 100644 --- a/Application/Admin/Controller/UserController.class.php +++ b/Application/Admin/Controller/UserController.class.php @@ -284,9 +284,16 @@ class UserController extends AdminController if (!empty($emailUser)) { $this->error('邮箱已存在!'); } + + $moblieUser = M('UcenterMember', 'sys_')->field('id')->where(['mobile' => $_POST['mobile']])->find(); + + if (!empty($moblieUser)) { + $this->error('手机号码已存在!'); + } + /* 调用注册接口注册用户 */ $User = new UserApi; - $uid = $User->register($username, $password, $email, $second_pwd); + $uid = $User->register($username, $password, $email, $second_pwd, $_POST['mobile']); if (0 < $uid) { //注册成功 $user = array('uid' => $uid,'real_name'=>$real_name, 'nickname' => $username, 'status' => 1,"birthday"=>date('Y-m-d',time())); $data['uid'] = $uid; @@ -373,21 +380,21 @@ class UserController extends AdminController if (!preg_match($pattern, $_POST['email'])) { $this->error('邮箱格式不正确!'); } - if (isset($_POST['mobile']) && $_POST['mobile'] != '') { - $dx = A('Phone'); - $res = $dx->check_tel_code($_POST['mobile'], $_POST['code']); - switch ($res) { - case '-1': - $this->error('短信验证码无效,请重新获取'); - break; - case '-2': - $this->error('时间超时,请重新获取短信验证码'); - break; - case '-3': - $this->error('短信验证码不正确,请重新输入'); - break; - } - } +// if (isset($_POST['mobile']) && $_POST['mobile'] != '') { +// $dx = A('Phone'); +// $res = $dx->check_tel_code($_POST['mobile'], $_POST['code']); +// switch ($res) { +// case '-1': +// $this->error('短信验证码无效,请重新获取'); +// break; +// case '-2': +// $this->error('时间超时,请重新获取短信验证码'); +// break; +// case '-3': +// $this->error('短信验证码不正确,请重新输入'); +// break; +// } +// } $Member = D('UcenterMember'); $mem = D('Member'); $au = D('AuthGroupAccess'); diff --git a/Application/Admin/View/User/add.html b/Application/Admin/View/User/add.html index 755d599e1..6de26319d 100644 --- a/Application/Admin/View/User/add.html +++ b/Application/Admin/View/User/add.html @@ -66,6 +66,13 @@ 管理员邮箱,用于找回密码等安全操作 + + 手机 + + + 管理员手机号码,用于找回密码等安全操作 + + diff --git a/Application/Admin/View/User/edit.html b/Application/Admin/View/User/edit.html index 815296928..db208188c 100644 --- a/Application/Admin/View/User/edit.html +++ b/Application/Admin/View/User/edit.html @@ -58,6 +58,16 @@ 管理员邮箱,用于找回密码等安全操作 + + 手机: + + + 管理员手机号码,用于找回密码等安全操作 + + + + + 手机: diff --git a/Application/User/Model/UcenterMemberModel.class.php b/Application/User/Model/UcenterMemberModel.class.php index 70953fe13..1c83af443 100644 --- a/Application/User/Model/UcenterMemberModel.class.php +++ b/Application/User/Model/UcenterMemberModel.class.php @@ -111,7 +111,7 @@ class UcenterMemberModel extends Model{ 'email' => $email, 'mobile' => $mobile, ); - + //验证手机 if(empty($data['mobile'])) unset($data['mobile']); /* 添加用户 */ @@ -120,6 +120,8 @@ class UcenterMemberModel extends Model{ $data['email'] = $email; $data['password'] = think_ucenter_md5($password, UC_AUTH_KEY); $data['second_pwd'] = think_ucenter_md5($second_pwd, UC_AUTH_KEY); + $data['mobile'] = $mobile; +// dump($data);die(); try { $status = M('UcenterMember', 'sys_')->add($data); } catch (\Throwable $th) {