0
votes

after I tried finding a solution using Google's search, I still haven't found anything which helped me. The problem is simple, I want to use another Model for the user authentication. The way the manual shows us does, somehow, not work.

My AppController looks like the follow:

public $components = array(
        'Auth',
        'DebugKit.Toolbar'
    );

    public function beforeFilter()
    {
        parent::beforeFilter();
        if (isset($this->request->params["intranet"]) && $this->request->params["intranet"] == 1) {
            $this->Auth = array(
            "loginAction" => array(
                "intranet" => true,
                "controller" => "employees",
                "action" => "login"
            ),
            "authenticate" => array(AuthComponent::ALL => array("userModel" => "Employee"))
        );
            $this->layout = "intranet";
        }
    }

It does not matter what url I open, CakePHP always redirects me to /users/login. Of course I run parent::beforeFilter() in the Controllers.

Edit: Okay seems like I missunderstand userModel, loginAction seem to be the right keyword here, but after I changed it to array("controller" => "employees", "action" => "login") it still redirects me to /users/login...

1
Have you tried putting parent::beforeFilter() at the end of your method?thaJeztah

1 Answers

0
votes

Oh my god I'm so dumb... I guess the most programmers already have a facepalm after reading this, but for the newer CakePHP/PHP developers who may struggle with the same problem:

In the code above, I override $this->Auth with the array. The solution:

$this->Auth->loginAction = array(
                "intranet" => true,
                "controller" => "employees",
                "action" => "login"
            );
            $this->Auth->authenticate = array(AuthComponent::ALL => array("userModel" => "Employee"));