Thursday, December 22, 2011

new action is being blocked by AuthComponent and I'm not sure why

Hi all,

I've implement the AuthComponent in my app and have gotten it working
well. Currently I've got it set up so that only the admin account can
create new users, and I'm adding some new functionality for users to
register themselves, and have the following form for that purpose:

<form method="post" action="/dev/users/success">
<label>Name: </label><input type="text" name="name" />
<label>E-mail Address:</label>
<input type="text" name="email" />
<input type="submit" name="submit" value="Register" />
</form>

I'm not using my User model for this form as I'll eventually be
integrating it into Paypal for users to make a payment to complete
registration.

Upon submitting the form, I'm getting redirected to the the login page
with the authError message. I've got the AuthComponent set up to do
authorization at the controller level. To troubleshoot this, I've
simplified my isAuthorized method in my UsersController to allow
everything:

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

But I'm still getting my authError message and getting redirected to
the login page. If I log in at this point with an existing account,
I'm redirected to my /dev/users/success action after logging in.

Here's my AuthComponent configuration in my AppController:

'Auth'=>array(
'loginRedirect'=>array('controller'=>'pages',
'action'=>'index'),
'logoutRedirect'=>array('controller'=>'pages',
'action'=>'index'),
'authError'=>"You can't access that page.",
'authorize'=>array("Controller")
)

I don't understand why AuthComponent is not authorizing this action
and I'm getting redirected even though I'm allowing all actions on the
controller though my isAuthorized method. Can anyone clue me in on
why this would be happening? I'm pretty sure I've got the
AuthComponent set up properly, as it was working fine before adding
this new success() action to my UsersController.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: