Example #1
0
 public function thirdlogincallbackAction()
 {
     $platform = $this->getInput('platform', 'get');
     if (!isset(PwThirdLoginService::$supportedPlatforms[$platform])) {
         $this->showError('USER:third.platform.error');
     }
     $service = new PwThirdLoginService();
     // TODO: 确认第三方返回的授权码
     $authcode = $this->getInput('code', 'get');
     $result = $service->getAccessToken($platform, $authcode);
     if (!$result[0]) {
         if (is_array($result[1])) {
             $error = new PwError('USER:third.platform.dataerror.detail', array('{code}' => $result[1][0], '{msg}' => $result[1][1]));
             $this->showError($error->getError());
         } else {
             $this->showError('USER:third.platform.dataerror');
         }
     }
     $accesstoken = $result[1];
     $result = $service->getUserInfo($platform, $accesstoken, $result['extra']);
     if (!$result[0]) {
         if (is_array($result[1])) {
             $error = new PwError('USER:third.platform.dataerror.detail', array('{code}' => $result[1]['code'], '{msg}' => $result[1]['msg']));
             $this->showError($error->getError());
         } else {
             $this->showError('USER:third.platform.dataerror');
         }
     }
     $userdata = $result[1];
     $acctRelationData = $this->_getUserOpenAccountDs()->getUid($userdata['uid'], $userdata['type']);
     //        var_dump($acctRelationData);exit;
     if (empty($acctRelationData)) {
         //如果没有这个用户,跳转到第三方登录注册页,$userdata内容保存到注册页面hidden
         //            var_dump($userdata,$_GET,$_POST);
         $this->setOutput($userdata, 'userdata');
     } else {
         //已经注册过,继续登录
         $login = new PwLoginService();
         $this->runHook('c_login_dorun', $login);
         Wind::import('SRV:user.srv.PwRegisterService');
         $registerService = new PwRegisterService();
         $info = $registerService->sysUser($acctRelationData['uid']);
         if (!$info) {
             $this->showError('USER:user.syn.error');
         }
         $identity = PwLoginService::createLoginIdentify($info);
         $identity = base64_encode($identity . '|' . $this->getInput('backurl') . '|' . '0');
         $this->forwardRedirect(WindUrlHelper::createUrl('u/login/welcome', array('_statu' => $identity)));
     }
 }
Example #2
0
 /**
  * 导航修改表单
  *
  * @return void
  */
 public function editAction()
 {
     $navId = $this->getInput('navid', 'get');
     $navInfo = $this->_getNavDs()->getNav($navId);
     if (empty($navInfo)) {
         $resource = new PwError('ADMIN:nav.edit.fail.error.navid');
         $this->showError($resource->getError());
     }
     list($navInfo['color'], $navInfo['bold'], $navInfo['italic'], $navInfo['underline']) = explode('|', $navInfo['style']);
     $navInfo['font'] = 'style=';
     !empty($navInfo['color']) && ($navInfo['font'] .= 'color:' . $navInfo['color'] . ';');
     !empty($navInfo['bold']) && ($navInfo['font'] .= 'font-weight:bold;');
     !empty($navInfo['italic']) && ($navInfo['font'] .= 'font-style:italic;');
     !empty($navInfo['underline']) && ($navInfo['font'] .= 'text-decoration:underline;');
     $this->_getNavType();
     $this->_navTab();
     $this->setOutput($this->_getRootNavOption($navInfo['parentid']), 'navOption');
     $this->setOutput($navInfo, 'navInfo');
 }