Ejemplo n.º 1
0
 public function editNameAction()
 {
     if (!$this->validFlag) {
         echo json_encode(array('ret' => 0, 'msg' => $this->warnMsg));
     } else {
         $users = new Users();
         if ($users->isNickExist($this->_sanReq['name']) == 1) {
             echo json_encode(array('ret' => 0, 'msg' => array('name' => array('msg' => $this->di['sysconfig']['flagMsg']['10014']))));
             $this->view->disable();
             return;
         }
         $users->changeNickname($this->session->get('uid'), $this->_sanReq['name']);
         $this->session->set('uinfo', array('name' => $this->_sanReq['name'], 'mobile' => $this->session->get('uinfo')['mobile']));
         // 更新redis用户信息
         $cas = new \Ucenter\Utils\cas\CAServer();
         $cas->setRedisUserInfo($this->session->get('uid'), array('name' => $this->_sanReq['name'], 'mobile' => $this->session->get('uinfo')['mobile']));
         echo json_encode(array('ret' => 1, 'nickName' => $this->_sanReq['name']));
     }
     $this->view->disable();
     return;
 }
Ejemplo n.º 2
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');
         }
     }
 }