Authorization adapter was not found in cakePHP

ぃ、小莉子 提交于 2019-12-07 06:36:44

问题


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

Thanks for the help


回答1:


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

So:

$this->Auth->authorize = 'Controller';

Instead of:

$this->Auth->authorize = 'controller';

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.



来源:https://stackoverflow.com/questions/10184388/authorization-adapter-was-not-found-in-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!