【问题标题】:Change the default redirection of croogo 1.3 (cakephp)更改croogo 1.3 (cakephp) 的默认重定向
【发布时间】:2014-09-27 02:03:05
【问题描述】:

我希望更改croogo 1.3“loginRedirect”的默认重定向

默认重定向是“用户/用户/登录”

我的情况是按角色重定向 [admin][register][...]

我的用户控制器(操作:登录):

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);
        }

    }           
}

重定向中的问题不起作用...当我有案例管理器'4'时...它始终是重定向到 /admin/index

【问题讨论】:

  • 这里有问题吗?
  • 你的代码在什么方面不起作用?请通过编辑问题来回答。
  • 是的,我这样做了,但它没有用....它总是重定向我用户/用户/登录
  • 通常当我担任案例经理角色“4”时,重定向将执行到 /managers/index....但情况并非如此
  • @AD7six 你没事吧??

标签: php cakephp mod-rewrite cakephp-1.3 croogo


【解决方案1】:

首先,

AuthComponent 不进行重定向。您需要致电

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

在您的 switch 声明之后。

其次,

这看起来不像 Croogo 1.3。事件只在 CakePHP 2.x 中引入,所以这至少必须是 Croogo 1.4.x。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 2014-04-16
    • 1970-01-01
    • 2011-12-01
    • 2012-03-18
    相关资源
    最近更新 更多