views:

91

answers:

1

Hi

I'm using CakePHP's Auth component and it's in my app_controller.php. The problem is I want to allow specific views in the built-in pages controller. How do I do that? Thanks in advance!

+3  A: 

Copy the pages_controller.php file in cake/libs/controllers to your app/controllers/ dir. Then you can modify it to do anything you want. With the auth component, the typical way to allow specific access is like this:

class PagesController extends AppController {
 ...
 function beforeFilter() {
  $this->Auth->allow( 'action1', 'allowedAction2' );
 }
 ...

I recommend highly copying the file to your controllers dir, rather than editing it in place, because it will make upgrading cake much easier, and less likely that you accidentally overwrite some stuff.

Travis Leleu
$this->Auth->allow('*'); will work fine too.
Wayne Khan
True, although that will allow all actions in the pages controller. I think the OP said that he wanted to allow access to everyone but only on specific views in the PC.
Travis Leleu