Reputation: 1065
This may be a repeated question but I have gone through all the other answers and none of them worked for me :(
The following is my code in AppController:
public $components = array(
'Auth',
'Session'
);
public function beforeFilter() {
$this->Auth->authorize = 'Controller';
$this->Auth->authenticate = array(
'Form' => array(
'fields' => array('username' => 'email', 'password' => 'password'),
'scope' => array('User.active' => 1),
'passwordHasher' => 'Blowfish'
)
);
}
public function isAuthorized($user) {
debug($this->request->params);
exit;
}
I am not overriding beforeFilter or isAuthorized function in any of the other controllers. No matter what page I open its not calling the isAuthorized function and taking me to the login page. Please Help!
Upvotes: 0
Views: 982
Reputation: 60463
Authorization checks are only made after successful authentication, see AuthComponent::startup()
.
public function startup(Controller $controller) {
// ...
// authenticate first
if (!$this->_getUser()) {
return $this->_unauthenticated($controller);
}
// then authorize
if ($this->_isLoginAction($controller) ||
empty($this->authorize) ||
$this->isAuthorized($this->user())
) {
return true;
}
// ...
}
So the solution should probably be to log in first.
Upvotes: 1