2012-02-15 86 views
0

我在我的应用程序中使用ACL和身份验证。CakePHP 1.3:登录时重定向

如果注销的用户将一个内部书签页面加载到该网站(家庭以外),Cake会正确提示登录。但是,一旦登录,它就会重定向到用户在登录之前试图访问的网址。

我需要让用户在登录后重定向到pages/home,而不管他们试图访问的URL。

到目前为止,我还没有找到$ this-> Auth命令来完成此操作。有任何想法吗?

这里是app_controller.php授权码

function beforeFilter() { 
    //Configure AuthComponent 
    //$this->Auth->allow(array('*')); 
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 
    $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login'); 
    $this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'home'); 
    $this->Auth->actionPath = 'controllers/'; 

感谢您的任何想法

回答

1

确保包括在beforeFilter函数如下:

function beforeFilter() { 
    $this->Auth->autoRedirect = false; 
    parent::beforeFilter(); 
} 

另外要确保你在登录功能中没有这样的东西:

$this->redirect($this->Auth->redirect()); 

Auth-> redirect()返回用户登录到登录页面或Auth-> loginRedirect之前所在的URL。

您应该可以在您的登录功能中使用$this->redirect或通过设置默认的登录重定向来重定向到任何你想要的地方。

+0

这似乎已经做到了!谢谢! – 2012-02-16 15:59:19