当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthComponent::redirect方法代码示例

本文整理汇总了PHP中AuthComponent::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthComponent::redirect方法的具体用法?PHP AuthComponent::redirect怎么用?PHP AuthComponent::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AuthComponent的用法示例。


在下文中一共展示了AuthComponent::redirect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: callback

 /**
  * OAuth callback
  */
 public function callback($datasource = null)
 {
     $this->Twitter->setTwitterSource($datasource);
     // 正当な返り値かチェック
     if (!$this->Twitter->isRequested()) {
         $this->Twitter->deleteAuthorizeCookie();
         $this->flash(__d('twitter_kit', 'Authorization failure.'), '/', 5);
         return;
     }
     // $tokenを取得
     $token = $this->Twitter->getAccessToken();
     if (is_string($token)) {
         $this->flash(__d('twitter_kit', 'Authorization Error: %s', $token), '/', 5);
         return;
     }
     if (class_exists('TwitterUser') || (true || App::uses('TwitterUser', 'Model')) && class_exists('TwitterUser')) {
         /* @var $model TwitterUser */
         $model = ClassRegistry::init('TwitterUser');
     } else {
         /* @var $model TwitterKitUser */
         $model = ClassRegistry::init('TwitterKit.TwitterKitUser');
     }
     // 保存データの作成
     $data = $model->createSaveDataByToken($token);
     if (!$model->save($data)) {
         $this->flash(__d('twitter_kit', 'The user could not be saved'), array('plugin' => 'twitter_kit', 'controller' => 'users', 'action' => 'login'), 5);
         return;
     }
     $this->Auth->login($data);
     // Redirect
     if (ini_get('session.referer_check') && env('HTTP_REFERER')) {
         $this->flash(__d('twiter_kit', 'Redirect to %s', Router::url($this->Auth->redirect(), true) . ini_get('session.referer_check')), $this->Auth->redirect(), 0);
         return;
     }
     $this->redirect($this->Auth->redirect());
 }
开发者ID:rasken2003,项目名称:trpg-ranking,代码行数:39,代码来源:OauthController.php

示例2: callback

 /**
  * OAuth callback
  */
 public function callback($datasource = null)
 {
     $this->Twitter->setTwitterSource($datasource);
     // 正当な返り値かチェック
     if (empty($this->params['url']['oauth_token']) || empty($this->params['url']['oauth_verifier'])) {
         $this->Twitter->deleteAuthorizeCookie();
         $this->flash(__d('twitter_kit', 'Authorization failure.', true), '/', 5);
         return;
     }
     // $tokenを取得
     $token = $this->Twitter->getAccessToken();
     if (is_string($token)) {
         $this->flash(__d('twitter_kit', 'Authorization Error: ', true) . $token, '/', 5);
         return;
     }
     if (ClassRegistry::isKeySet('TwitterUser')) {
         /* @var $model TwitterUser */
         $model = ClassRegistry::init('TwitterUser');
     } else {
         /* @var $model TwitterKitUser */
         $model = ClassRegistry::init('TwitterKit.TwitterKitUser');
     }
     // 保存データの作成
     $data = $model->createSaveDataByToken($token);
     if (!$model->save($data)) {
         $this->flash(__d('twitter_kit', 'The user could not be saved', true), array('plugin' => 'twitter_kit', 'controller' => 'users', 'action' => 'login'), 5);
         return;
     }
     $this->Auth->login($data);
     // Redirect
     if (ini_get('session.referer_check') && env('HTTP_REFERER')) {
         $this->flash(sprintf(__d('twiter_kit', 'Redirect to %s', true), Router::url($this->Auth->redirect(), true) . ini_get('session.referer_check')), $this->Auth->redirect(), 0);
         return;
     }
     $this->redirect($this->Auth->redirect());
 }
开发者ID:hiromi2424,项目名称:twitter_kit,代码行数:39,代码来源:oauth_controller.php

示例3: callback

 /**
  * OAuth callback
  */
 public function callback($datasource = null)
 {
     $this->Twitter->setTwitterSource($datasource);
     // 正当な返り値かチェック
     if (!$this->Twitter->isRequested()) {
         $this->Twitter->deleteAuthorizeCookie();
         $this->flash(__d('twitter_kit', 'Authorization failure.'), '/', 5);
         return;
     }
     // $tokenを取得
     $token = $this->Twitter->getAccessToken();
     if (is_string($token)) {
         $this->flash(__d('twitter_kit', 'Authorization Error: %s', $token), '/', 5);
         return;
     }
     if (class_exists('TwitterUser') || (true || App::uses('TwitterUser', 'Model')) && class_exists('TwitterUser')) {
         /* @var $model TwitterUser */
         $model = ClassRegistry::init('TwitterUser');
     } else {
         /* @var $model TwitterKitUser */
         //$model = ClassRegistry::init('TwitterKit.TwitterKitUser');
         $model = ClassRegistry::init('User');
     }
     $create_flg = false;
     //既に登録済みか?
     $tmp = $model->findTwitterUser($token['user_id']);
     if (!empty($tmp)) {
         $data = $model->updateSaveDataByToken($tmp, $token);
     } else {
         // 保存データの作成
         $data = $model->createSaveDataByToken($token);
         $model->create();
         $create_flg = true;
     }
     if (!$model->save($data, false)) {
         $this->flash(__d('twitter_kit', 'The user could not be saved'), array('plugin' => 'twitter_kit', 'controller' => 'users', 'action' => 'login'), 5);
         return;
     }
     if ($create_flg == true) {
         $data['User']['id'] = $model->getLastInsertId();
         //新規会員登録の際
         $ds = $this->Twitter->getTwitterSource();
         $ds->setToken($data['User']);
         //プロフィール画像の取得
         $params = array();
         $params['id'] = $data['User']['twitter_user_id'];
         $result = $ds->users_show($data['User']['twitter_user_id']);
         if (!empty($result['profile_image_url'])) {
             $image_url = str_replace("_normal", "", $result['profile_image_url']);
             $image_data = file_get_contents($image_url);
             //MIMEタイプの取得
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
             $mime_type = finfo_buffer($finfo, $image_data);
             finfo_close($finfo);
             //出力
             switch ($mime_type) {
                 case 'image/gif':
                     $ext = "gif";
                     break;
                 case 'image/png':
                     $ext = "png";
                     break;
                 case 'image/jpg':
                 case 'image/jpeg':
                     $ext = "jpg";
                     break;
             }
             $file_name = md5(date("YmdHis") . $data['User']['id']) . "." . $ext;
             file_put_contents(IMAGES . 'profileImg/' . $file_name, $image_data);
             //profile_imgを更新
             $model->id = $data['User']['id'];
             $model->saveField('profile_img', $file_name);
             $data['User']['profile_img'] = $file_name;
         }
         //メール送信
         $email = new CakeEmail('smtp');
         $email->to('info@sanrentan-box.com');
         $email->subject('twitterから会員登録がありました');
         $email->emailFormat('text');
         $email->template('regist');
         $postData['User']['nickname'] = $data['User']['nickname'];
         $email->viewVars(compact('postData'));
         $email->send();
     }
     $this->Auth->login($data['User']);
     // Redirect
     if (ini_get('session.referer_check') && env('HTTP_REFERER')) {
         $this->flash(__d('twiter_kit', 'Redirect to %s', Router::url($this->Auth->redirect(), true) . ini_get('session.referer_check')), $this->Auth->redirect(), 0);
         return;
     }
     //ログイン履歴を保存
     $this->LoginHistory->saveLoginHistory($data['User']['id'], $this->request);
     //$this->redirect($this->Auth->redirect());
     if ($create_flg == true) {
         $this->redirect("/users/edit");
     } else {
         $this->redirect("/");
//.........这里部分代码省略.........
开发者ID:sanrentan,项目名称:sanrentan,代码行数:101,代码来源:OauthController.php


注:本文中的AuthComponent::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。