我有一个小问题,我不确定它是路由问题还是我的登录功能有问题。我有这个ACL插件,我买了并集成到我的应用程序。也就是说,登录功能是内置在插件中,所以我编辑我的路由如下
Router::connect('/', array('plugin' => 'AuthAcl', 'controller' => 'users', 'action' => 'login', 'home'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
现在登录将工作,但当我登录它看起来像这样localhost/app/app代替localhost/app.
我看不出路由有什么问题。
我的登录功能如下
public function login() {
$this->layout = 'admin_login';
$this->Session->delete('auth_user');
App::uses('Setting', 'AuthAcl.Model');
$Setting = new Setting();
$error = null;
$general = $Setting->find('first',array('conditions' => array('setting_key' => sha1('general'))));
if (!empty($general)){
$general = unserialize($general['Setting']['setting_value']);
}
$this->set('general',$general);
$user = $this->Auth->user();
if(!empty($user)){
$this->redirect($this->Auth->redirect());
}
if ($this->request->is('post')) {
if ($this->Auth->login()) {
if ((int)$this->request->data['User']['remember_me'] == 0){
$this->Cookie->delete('AutoLoginUser');
}else{
$this->Cookie->write('AutoLoginUser', $this->Auth->user(), true, '+2 weeks');
}
$this->redirect($this->Auth->redirect());
} else {
$error = __('Your username or password was incorrect.');
}
}
$this->set('error',$error);
为什么我登录时没有正确重定向。
好了,下面是我解决这个问题的方法。我指向我希望用户重定向到的控制器。谢谢user221931 !
$this->redirect($this->Auth->redirectUrl('auth_acl'));