我希望改变CrogoG1.3 "loginRedirect“的默认重定向。
默认重定向为'users / users /login‘
我的案例是通过角色管理员重定向...
我的登录(操作: UsersController ):
public function login() {
$this->set('title_for_layout', __d('croogo', 'Log in'));
if ($this->request->is('post')) {
Croogo::dispatchEvent('Controller.Users.beforeLogin', $this);
if ($this->Auth->login()) {
switch($this->Auth->user('role_id')){
case '1': // admin
$this->Auth->loginRedirect = array('controller'=>'users','action'=>'admin_index','prefix'=>'admin','admin'=>true);
break;
case '4': // manager
$this->Auth->loginRedirect = array('controller'=>'managers','action'=>'index','prefix'=>'','manager'=>true);
break;
}
} else {
Croogo::dispatchEvent('Controller.Users.loginFailure', $this);
$this->Session->setFlash($this->Auth->authError, 'default', array('class' => 'error'), 'auth');
$this->redirect($this->Auth->loginAction);
}
}
}重定向中的问题没有work...when我有案例管理器'4 '....它总是重定向到/admin/index
发布于 2014-08-05 13:55:38
首先,
AuthComponent不执行重定向。您需要调用
$this->redirect($this->Auth->redirect());在您的switch语句之后。
第二,
这看起来不像是Crogo1.3。事件只在CroOgo2.x中引入,所以至少必须是CakePHP 1.4.x。
https://stackoverflow.com/questions/25121368
复制相似问题