本文整理汇总了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());
}
示例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());
}
示例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("/");
//.........这里部分代码省略.........