CakePHP的坏验证重定向 [英] CakePhp bad Auth redirection

查看:154
本文介绍了CakePHP的坏验证重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习的验证组件,我在与重定向的一个问题。我的本地aplication的路径是:本地主​​机/学校,但是,当登录用户试图查看在一个url他isnt't允许的网站重定向到本地主机/学校/学院和它说:请求的地址'/学校/学校/在这个服务器上没找到。我想没有重定向发生这种情况时,只显示你不准在同一个页面或者重定向到特定的错误页面,我怎么能做到这一点?我有一个登录或注销重定向,只有我之前说的没有问题。这是我的应用程序控制器:

公共$组件=阵列(
        '的ACL',
        '验证'=>阵列(
            '授权'=>阵列(
                操作=>阵列('actionPath'=>'控制器)
            )
        )
        会话
    );
    公共$佣工=阵列(HTML,形式,会话);

 公共职能beforeFilter(){
    //配置AuthComponent    $这个 - > Auth->在loginAction =阵列(
        控制器=> '用户',
        '行动'=> '登录'
    );
    $这个 - > Auth-> logoutRedirect =阵列(
        控制器=> '用户',
        '行动'=> '登录'
    );    $这个 - >设置('CURRENT_USER',$这个 - > Auth->用户());
    $这个 - > Auth-> authError =你不允许的。
}


解决方案

本地主机/项目名称/项目名称是当你没有权限来此操作的重定向。我有同样的问题。我一会儿操作= GT意见;阵列('actionPath'=>'控制器')) $组件。从那以后,我将 aros_acos 通过执行此code:

  $组= $这个 - >用户 - >及集团 -  GT;读(NULL,'1');
$这个 - >&ACL的GT;允许($组,控制器/用户/ ControlPanel控制');

这是我去掉code,并在行动ControlPanel控制和错误消失了:)我不知道我怎样才能改变这种重定向,但之后,如果我有记录 aros_acos 一切正常。

I just started learning about the Auth component and I'm having a problem with redirection. The path of my local aplication is: localhost/school but when a logged user tries to acces to a url he isnt't allowed the site redirects to localhost/school/school and it says "The requested address '/school/school/' was not found on this server". I want no redirection when this happens, just show "you are not allowed" in the same page or maybe redirect to specific error page, how can I do that?. I have no problems with login or logout redirection, only what I said before. This is my App Controller:

public $components = array( 'Acl', 'Auth' => array( 'authorize' => array( 'Actions' => array('actionPath' => 'controllers') ) ), 'Session' ); public $helpers = array('Html', 'Form', 'Session');

public function beforeFilter() {
    //Configure AuthComponent

    $this->Auth->loginAction = array(
        'controller' => 'users',
        'action' => 'login'
    );
    $this->Auth->logoutRedirect = array(
        'controller' => 'users',
        'action' => 'login'
    );

    $this->set('current_user',$this->Auth->User());
    $this->Auth->authError = "You're not allowed.";
}

解决方案

localhost/projectName/projectName is a redirection when you don't have permission to this action. I had same problem. I comment for a moment 'Actions' => array('actionPath' => 'controllers') ) in $components. After that I set aros_acos by executing this code:

$group = $this->User->Group->read(null,'1');
$this->Acl->allow($group, 'controllers/Users/controlPanel');

After that I uncomment code, and in action 'controlPanel' and error disappear :) I don't know how I can change this redirection, but if I have record in aros_acos everything works.

这篇关于CakePHP的坏验证重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆