Thank you, Miles. I have another question. class AppController extends Controller { var $uses = array('User'); var $helpers = array('Form', 'Html', 'Pagination','Javascript','Ajax'); var $components = array('Acl','Email','Auth'); function beforeFilter() {//....} }
class PostsController extends AppController { var $name = 'Posts'; var $components = array('Pagination','Acl','RequestHandler'); //.... //anonymous user can also view the post detail too. function detail($id){ //... } } When I try to call 'http://..../posts/detail/2', the page will redirect to users::login page. I dig into the source of Dispatcher::_invoke() , there is a line: //code $controller->Component->startup($controller); //code end When I invoke this url, the Auth::startup method wil be invoked. And you can this source block //code if ($loginAction == $url) { //.... }else{ if (!$this->user()) { if (!$this->RequestHandler->isAjax()) { $this->Session->setFlash($this->authError, 'default', array(), 'auth'); $this->Session->write('Auth.redirect', $url); $controller->redirect($loginAction); return false; } elseif (!empty($this->ajaxLogin)) { //... } else { //.... } } } //code end It is here that my action was redirected. That is why I doubt should we put the Auth component in Appcontroller at my first post. Where I have made mistake at again? On Thu, Mar 5, 2009 at 10:50 AM, Miles J <mileswjohn...@gmail.com> wrote: > > Your doing Auth all wrong. > > http://www.milesj.me/blog/read/5/using-cakephps-auth-component > > > -- Thanks Joshua --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---