This solution works only in this special case, for pages_controller.
For another controllers, it doesn't work.

I explain my situation: I added in my app_controller the Auth
component and configure it to allow 'display' (I suppose you've the
same tekomp):

   //Set application wide actions which do not require authentication.
   $this->Auth->allow('display');

All my static pages located in the pages folder are accessible to
public users and all others actions are limited to registered users of
my application.

Of course, I have classical functions like registration that need a
public access, so I created a public controller which contains all
public functionalities accessible to public users. I tried to make
like tekomp to allow all these functionalities:

  //Retrieve application controller configuration for the Auth
component.
  parent::beforeFilter();
  //Set application wide actions which do not require authentication.
  $this->Auth->allow('*');

It didn't work. Then I found this post and tried to use the 'display'
but the result was the same, it didn't work. The only solution which
works is the following:
  //Retrieve application controller configuration for the Auth
component.
  parent::beforeFilter();
  //Set application wide actions which do not require authentication.
  $this->Auth->allow();

The allow method without parameters works to allow all functionalities
of a controller. I read the Auth component to discover this solution

In fact, I think there is a bug in the Auth component. When you call
the parent::BeforeFilter and you set a new value to the Auth variable
allow (what I do above with a star for all cations), a merge of the
two arrays of actions (actions allowed from the app_controller and
actions allowed of the called controller) is done. It means you obtain
an array like that for your allowed actions: array('display', '*').
Till this point, there is no problem.

But now if we check the test in the Auth component which tests if an
action is allowed, we can see the following line:
  if ($loginAction != $url && ($this->allowedActions == array('*') ||
in_array($controller->action, $this->allowedActions)))...

And I think the $this->allowedActions == array('*') condition is
incorrect. I change it for this line:
  if ($loginAction != $url && (in_array('*', $this->allowedActions) ||
in_array($controller->action, $this->allowedActions)))
and now my Auth component works perfectly when I use a star to define
all actions.

Somebody to check this problem and confirm we face a bug?

On Aug 24, 2:09 pm, tekomp <[EMAIL PROTECTED]> wrote:
> I was still having a problem with it because I created my own
> pages_controller.php.  Once I copied the default one from /cake/libs/
> controller/pages_controller.php and added the snippets posted here, I
> was able to override the display action and all my "pages" didn't
> require authorization, while at the same time still have the Auth
> component work in the background.
>
> On Aug 23, 3:49 pm, tekomp <[EMAIL PROTECTED]> wrote:
>
> > I'm using the Auth Component in my app_controller.php in the
> > beforeFilter function, which is great for making people login, but I'm
> > having a hard time allowing certain pages.  I want all pages in my
> > "Pages" controller to not require authorization, so I added 
> > $this->Auth->allow('*')  in my beforeFilter in pages_controller.php.
>
> > Problem with that is that it overrides the beforeFilter in
> > app_controller.php and I cannot access $this->Auth.  I tried adding
> > parent::beforeFilter in pages_controller.php, but it then does not
> > recognize my $this->Auth->allow('*').
>
> > I've tried a number of things and read all the tutorials I could find,
> > but still can't find a way to allow an entire controller while
> > maintaining this->Auth.  It doesn't seem right that I'd have to add
> > the Auth code to each individual controller.
>
> > Any ideas?
>
> > Thanks.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to