Пример #1
0
 public function setPwdAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         $user = new User();
         $data = $user->getUid($this->session->get('resetMobile'));
         $res = $user->changePwd($data['u_id'], $this->_sanReq['passwd']);
         if ($res) {
             $this->session->remove('resetToken');
             $this->session->remove('resetMobile');
             echo json_encode(array('ret' => 1));
         }
     }
     exit;
 }
Пример #2
0
 /**
  * [sendMailAction 发送邮件]
  * @return [type] [description]
  */
 public function sendMailAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         if (isset($this->_sanReq['mobile'])) {
             $email = $this->_sanReq['email'];
         } else {
             $user = new User();
             $userinfo = $user->getUserInfo($this->session->get('uid'));
             $email = $userinfo['u_email'];
         }
         $Service = new Service($this->di);
         $Service->sendMails($this->session->get('uid'), $email);
         echo json_encode(array('ret' => 1));
     }
     exit;
 }
Пример #3
0
 /**
  * [resetEmailAction 重置邮箱]
  * @return [type] [1 修改成功,10015 该邮件已存在,10031 非法操作]
  */
 public function resetEmailAction()
 {
     if (empty($this->session->get('emailToken'))) {
         echo json_encode(array('ret' => 0, 'msg' => array('email' => array('msg' => $this->di['sysconfig']['flagMsg']['10031']))));
     }
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         $user = new User();
         $res = $user->isEmailExist($this->_sanReq['email']);
         if ($res['u_email']) {
             echo json_encode(array('ret' => 0, 'msg' => array('email' => array('msg' => $this->di['sysconfig']['flagMsg']['10015']))));
         } else {
             $res = $user->resetEmail($this->session->get('uid'), $this->_sanReq['email']);
             if ($res) {
                 $Service = new Service($this->di);
                 $Service->sendMails($this->session->get('uid'), $this->_sanReq['email']);
                 $this->session->remove('emailToken');
                 echo json_encode(array('ret' => 1));
             }
         }
     }
     exit;
 }
Пример #4
0
 public function alipayCallbackAction()
 {
     $alipay = new \Ucenter\Utils\AlipayApi($this->di);
     $acInfo = $alipay->verifyReturn();
     if (!$acInfo) {
         header('Location: /');
     }
     $openId = $_GET['user_id'];
     if ($this->session->has('uid') && isset($openId)) {
         $user = new Users();
         // 校验该第三方账号是否已存在
         if ($user->getUinfo($openId, 'alipay')) {
             echo '<script>alert("绑定失败,该账号已绑定其他用户");window.location.href="/user/accountbind";</script>';
             return;
         } else {
             if ($user->bindAlipay($this->session->get('uid'), $openId)) {
                 $this->response->redirect('user/accountbind');
             } else {
                 throw new E('Ailpay bind failed');
             }
         }
     } else {
         $user = new Users();
         if ($uinfo = $user->getUinfo($openId, 'alipay')) {
             $cas = new \Ucenter\Utils\cas\CAServer();
             $this->session->set('uid', $uinfo['u_id']);
             $this->session->set('uinfo', array('name' => $uinfo['u_name'], 'mobile' => $uinfo['u_mobi']));
             $cas->casSave(0, 0);
             $this->response->redirect('user/index');
         } else {
             //获取用户信息
             $uidInfo = $_GET;
             if (!isset($uidInfo['user_id'])) {
                 header('Location: /');
             }
             $info = array('type' => 'alipay', 'name' => $uidInfo['real_name'], 'uids' => $openId, 'pic' => '');
             setcookie(substr(md5('tmpQqWb'), 8, 20), base64_encode(json_encode($info)), $_SERVER['REQUEST_TIME'] + 1800, '/');
             $this->response->redirect('index/addUserInfo');
         }
     }
 }
Пример #5
0
 private function _autoLogin()
 {
     if (empty($this->session->get('uid'))) {
         $key = substr(md5($this->di['sysconfig']['siteUrl']), 5, 15);
         if ($this->cookies->has($key)) {
             $val = explode(':', base64_decode($this->cookies->get($key)));
             $uid = base64_decode($val[1]);
             $time = base64_decode($val[2]);
             $user = new Users();
             $userInfo = $user->getUserInfo($uid);
             if ($time == $userInfo['u_last_logintime']) {
                 if ($val[0] === substr(md5($userInfo['u_mobi']), 8, 20)) {
                     $this->session->set('uid', $userInfo['u_id']);
                     $this->session->set('uinfo', array('name' => $userInfo['u_name'], 'mobile' => $userInfo['u_mobi']));
                     $this->response->redirect('user/index');
                 }
             }
         }
     } else {
         $this->response->redirect('user/index');
     }
 }
Пример #6
0
 /**
  * Captcha 1验证码有效 2验证码失效 3验证码错误 4需要图像验证码 5图像验证码错误
  */
 public function editPasswdAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         $objCaptcha = new Captcha();
         $key = 'editPwd:' . $this->session->get('uinfo')['mobile'];
         $data = $objCaptcha->checkAllCaptcha($this->session->get('uinfo')['mobile'], $this->_sanReq['codeImg'], $key, $this->_sanReq['regtype'], $this->_sanReq['captcha']);
         if ($data == 1) {
             $users = new Users();
             $users->changePwd($this->session->get('uid'), $this->_sanReq['passwd']);
             $objCaptcha->delCaptchaRedisKey($key);
             echo json_encode(array('ret' => 1));
         } else {
             echo json_encode(array('ret' => 0, 'msg' => $data));
         }
     }
     $this->view->disable();
     return;
 }