예제 #1
0
 public function oauth()
 {
     $type = $this->request->get('type');
     if (is_null($type)) {
         $this->widget('Widget_Notice')->set(array('请选择登录方式!'), 'error');
         $this->response->goBack();
     }
     $options = TeConnect_Plugin::options();
     $tyle = strtolower($type);
     //不在开启的登陆方式内直接返回
     if (!isset($options[$type])) {
         $this->widget('Widget_Notice')->set(array('暂不支持该登录方式!'), 'error');
         $this->response->goBack();
     }
     $callback_url = Typecho_Common::url('/oauth_callback?type=' . $type, $this->options->index);
     require_once 'Connect.php';
     $this->response->redirect(Connect::getLoginUrl($type, $callback_url));
 }
예제 #2
0
파일: Oauth.php 프로젝트: dccecc/typecho
 /**
  * 构造oauth链接
  */
 public function oauth()
 {
     $this->auth['type'] = $this->request->get('type');
     $this->auth['code'] = $this->request->get('code');
     if (!empty($this->auth['code'])) {
         $this->callback();
     } else {
         if (is_null($this->auth['type'])) {
             $this->widget('Widget_Notice')->set(array('请选择登录方式!'), 'error');
             $this->response->redirect($this->___loginUrl());
         }
         //是否允许使用
         if (!$this->allowConnect($this->auth['type'])) {
             $this->widget('Widget_Notice')->set(array('暂不支持该登录方式!'), 'error');
             $this->response->goBack();
         }
         $callback_url = Typecho_Common::url('/user/oauth?type=' . $this->auth['type'], $this->options->index);
         require_once 'Connect.php';
         $this->response->redirect(Connect::getLoginUrl($this->auth['type'], $callback_url));
     }
 }