public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
}
这是我的登录脚本和
public $components = array('Acl', 'Session',
'Auth' => array('authorize' => array('Controller'),
'loginRedirect' => array('controller' => 'users', 'action' => 'dashboard'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
'authenticate' => array('Form' => array('fields' => array('username' => 'email')))
)
);
这是appcontroller.php中的auth compnents
它使用电子邮件和密码登录,但未重定向到用户/仪表板
但是,如果我放置任何外部网址,它会完全重定向
eg: 'loginRedirect' => 'http://google.com',
重定向到谷歌
我完全迷失了。求助
答案 0 :(得分:1)
确保您可以使用以下网址查看信息中心页面:AuthComponent::allow()
:
将此方法添加到您的控制器:
public function beforeFilter() {
$this->Auth->allow('dashboard');
}
确保为仪表板页面设置了路径