リファラーページに戻る際に問題があります:
first url: http://site.com/venue/apartments/1564/venue-name
referer url: null
このページでは、内部の内容を編集できるのでlogin、ログイン ページに移動するボタンがあります。ログインに成功したら、first url.
second url: http://site.com/users/login
referer url: http://site.com/venue/apartments/1564/venue-name
ログインしようとすると、CakePHP のアクション ルールが原因で、ログイン ページを更新して資格情報を確認する必要problemがあります。
third url: http://site.com/users/login
referer url: http://site.com/users/login
loginページを更新し、コントローラーのアクションで資格情報を確認すると、users以前と同じページを参照するようになり、first url.
loginアクションページにいないかどうかを確認するAppControllerにセッション変数を設定し、これを行うことで、いくつかの解決策を試しました。
AppController.php
public function beforeFilter () {
$this->setRedirect();
}
public function setRedirect () {
if ($this->request->params['controller'] != 'users' && $this->request->params['action'] != 'login') {
$this->Session->write('redir', array('controller'=>$this->request->params['controller'], 'action'=>$this->request->params['action'], implode($this->request->params['pass'], '/')));
}
}
セッション変数をdebug($this->Session->write('redir'));すべてでテストすると、アクションに行くまで完璧に動作するように見えますlogin:
UsersController.php
public function login () {
if ($this->request->is ('post')){
if ($this->Auth->login()) {
$redir = $this->Session->read('redir');
if (!empty($redir)) {
$this->redirect ($redir);
} else {
$this->redirect ($this->Auth->redirect());
}
}
}
}
これを行うとアプリケーションが壊れ、debug($redir);var の場合は次のようになります。
array(
'controller' => 'js',
'action' => 'jquery',
(int) 0 => 'plugin/jquery.validata.1.7.min' // just a jquery plugin loaded in default.ctp
)
それ以外の
array(
'controller' => 'venue',
'action' => 'apartments',
(int) 0 => '1564/venue-name'
)
サイト全体の他のビューでdebug($redir);は、すべてがうまく機能し、適切なデータが得られます。
アクションのためのある種のセッション保護ルーチンを考えまし$this->Auth->login()たが、それは私にとってまったくナンセンスです。
ログインしたユーザーを、表示ページではない最後のページにリダイレクトするにはどうすればよいloginですか?