I found an acl tutorial that has an access helper and comp. The access helper checks acl permissions before outputing links.
All works fairly well, though I do have reservations about the way it crosses the view and controller streams This is the link http://net.tutsplus.com/tutorials/php/how-to-use-cakephps-access-control-lists/ - S On 2 Dec 2011 10:29, "euromark" <[email protected]> wrote: > i think it is possible but would create quite some overhead... > and yes, it would probably break MVC > > On 2 Dez., 10:16, Dan <[email protected]> wrote: > > I would like to write a Helper which would check if a given link is > > authorized for the current user. > > > > I'm using CakePHP 2.0. I'm using the AuthComponent with controller > > authorization. So my authorization logic goes into isAuthorized > callbacks. > > > > The idea would be to have a helper used in this manner : > > $this->MyAuthHelper->link(__('Edit'), array('action' => 'edit', > > $user['User']['id'])); > > > > The MyAuthHelper would check if the current controller action edit with > the > > passed parameter is accessible for the current user. If that's the case, > it > > returns the link, otherwise it returns nothing. > > > > I manage to parse the url this way : $parsedUrl = > > Router::parse(Router::normalize(Router::url($url))); > > But then I would like to call the AuthComponent::isAuthorized method, > > passing the requested url. > > > > I see in AuthComponent the method : public function isAuthorized($user = > > null, $request = null) > > So I could write something like : isAuthorized(null, new > > CakeRequest($parsedUrl, false)) // false parameter to prevent to parse > > the environment ie. GET, POST, FILES > > > > But how could I access the AuthComponent from my helper ?? It seems to > > break the MVC. Any great ideas out there ? > > > > Thanks for reading. > > -- > 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 > [email protected] For more options, visit this group > at http://groups.google.com/group/cake-php > -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
