授权适配器没有在CakePHP中找到 [英] Authorization adapter was not found in cakePHP

查看:133
本文介绍了授权适配器没有在CakePHP中找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从本地移动我的code服务器
当我尝试登录到应用程序

I'm trying to move my code from local to server when i try to login into the application

Here is my AppController
class AppController extends Controller{
    /*  Determines what logged-in users access to */
    var $components = array('Auth','Session');

    public function isAuthorized($user){
        return true;
    }

    public function beforeFilter(){
        $userdetails = array();
        $this->Auth->autoRedirect = false;
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'matches', 'action' => 'index');
        $this->Auth->authorize = 'controller';
        $this->Auth->authError= 'You need permissions to access this page';
        $this->Auth->allow('users');
        $this->set('Auth',$this->Auth);
        $userdetails = $this->Auth->user();
        $this->set('myUser', $userdetails['username']);
        $this->set('myRole', $userdetails['user_role_id']);
        $this->set('pStatus', $userdetails['password_status']);
    }
}


Here is my Login Action in UsersController
public function login(){
        $this->Auth->autoRedirect = false;
        $id = $this->Auth->user('id');
        if(empty($id)){
            if($this->request->is('post')){
                if($this->Auth->login()){
                    $this->redirect($this->Auth->redirect());   
                }else{
                    $this->Session->setFlash('Invalid Username or password');
                }
            }
        }else{
            $this->redirect(array('action'=>'index'));
        }   
    }

感谢您的帮助。

推荐答案

在这里你授权的控制器部分的 beforeFilter 应正确大写:

The part where you authorise controllers in your beforeFilter should be capitalised properly:

所以:

$这个 - > Auth->授权='控制';

而不是:

$这个 - > Auth->授权=控制器;

这特定的语句试图找到 controllerAuthorize.php 和应该寻找 ControllerAuthorize.php 。这不会导致Windows上的问题,但它确实在Unix系统上。

That particular statement tries to find controllerAuthorize.php and should be looking for ControllerAuthorize.php. This doesn't cause a problem on Windows, but it does on Unix systems.

这篇关于授权适配器没有在CakePHP中找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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