###前提・実現したいこと
CakePHP2.6にてAuth認証にて、以下の機能を実現したいと思っています。
・ログイン後の画面でブラウザバックをしログイン画面に戻った場合、ログイン後の画面にリダイレクト ・ログイン状態からブラウザを閉じ、新規ブラウザでログイン画面を開いた場合、ブラウザを閉じたときの画面にリダイレクト
CookBookを参考に以下のソースのように作成しまして、
ログイン画面 ⇒/localhost/users/login
ログイン後画面⇒/localhost/menu/
とし、通常の自動ログインはできました。
###ソースコード
PHP
1//AppController.php 2class AppController extends Controller { 3 4 public $components = array( 5 'Auth' => array( 6 'loginRedirect' => array('controller' => 'menu', 'action' => 'index'), 7 'logoutRedirect' => array('controller' => 'users','action' => 'login'), 8 'authenticate' => array( 9 'Form' => array('passwordHasher' => 'Blowfish') 10 ) 11 ) 12 ); 13 14// UsersController.php 15public function login() { 16 if ($this->request->is('post')) { 17 if ($this->Auth->login()) { 18 $this->redirect($this->Auth->redirectUrl()); 19 } else { 20 $this->Flash->error(__('LOGINERR')); 21 } 22 } 23} 24public function logout() { 25 $this->redirect($this->Auth->logout()); 26}
###試したこと
loginアクションの$this->request->is('post')のelseを作成し、その中でログイン認証OKなら
refererやらredirectUrlにリダイレクトするようにしてみたのですが
操作によっては無限ループになってしまい…
初心者で申し訳ないのですが、どなたかご指導いただければ助かります。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/26 23:20 編集
2017/04/27 00:15 編集
2017/04/27 03:16
2017/04/27 04:04 編集
2017/04/27 10:06
2017/04/27 11:07
2017/04/27 11:11