Wednesday, May 12, 2010

Authorizing problems with Auth compoment.

The problem confucing me is that when i using Auth, every action that
i not allowed in the

Auth->allow()
will be access denied even after i loged in with a correct username
and password.
Am i missunderstanding the usage of Auth component? only the allowed
actions can be accessed?

/* app/app_controller */
var $components = array('Auth');

function beforeFilter()
{

$this->Auth->fields = array('username' => 'email', 'password' =>
'password');

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

$this->Auth->loginRedirect = array('controller' => 'users', 'action'
=> 'home');

$this->Auth->logoutRedirect = '/';

$this->Auth->loginError = 'Invalid e-mail / password combination.
Please try again';

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

}

/*==============im a seperator ==============================*/

/*users controller*/
var $name = 'Users';
var $components = array('Session');

function beforeFilter(){
$this->Auth->allow('login','logout','signup');
parent::beforeFilter();
}

function login()
{
// its blank.....

}
function home()
{
// do somthing homepage.....
}


with these codes, when i sign in with a correct account, it will
successfully sign in then redirected to users/home action, but because
'home' action is not in the allow list , it's again redirected to the
loginAction with a flash message of 'You are not authorized to access
that location'(other not allowed actions for the same). But if i put
home action in the $this->Auth->allow(), it will be displayed well
with the correct user informations........

By my understanding of Auth component, it should be displaying home
action cause ive already logged in. Am i wrong or doing something in a
wrong way ?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate