Friday, November 23, 2012

Re: Auth allow for shared functions in Appcontroller

Like this:  

AppController

public $components = array(
        'Acl',
        'Auth' => array(
'loginAction' => '/',
'loginRedirect' => '/users/dashboard',
            'logoutRedirect' => array('admin'=>false,'controller'=>'pages','action'=>'home'),
'autoRedirect'   => false,
            'authorize' => array(
                'Actions' => array(
'actionPath' => 'controllers'
)
            ),
'authError' => 'No access',
        ),
        'Session',
'Security',
'Cookie'
    );

public function beforeFilter() {
  // unquoting this line will cause App to crash
  // $this->Auth->allow('TellaFriend')
}

PageController

public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('home','view');
}

And using cake 2.3 beta

So? Doing anything wrong?

-Tom

kl. 20:20:52 UTC+1 fredag 23. november 2012 skrev cricket følgende:
On Fri, Nov 23, 2012 at 5:37 AM, MetZ <met...@gmail.com> wrote:
>
> So, what to put where?
>
> eg: PageController
> $this->allowedActions = array_merge($this->allowedActions, $args);

No, no. This line is from AuthComponent. I just mentioned it to point
out that calling allow() in AppController *and* your regular
controller should work just fine.

So how are you initialising Auth? In the $components array or in beforeFilter()?

What you want to do is possible so you've probably either got
something misconfigured somewhere or you're calling something
where/when you shouldn't be.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: