rgreenphotodesign gave the right code, but I'm going to *guess* it won't work as-is. If by "index" you meant the home page of your site (home.ctp), you actually need to allow the PagesController method of "display". Therefore, in your AppController, you'd add:
//App Controller -- global controller function beforeFilter() { $this->Auth->allow('display'); } The Pages Controller handles all "page" elements that are static and do not have any CakePHP models/controllers directly associated with them. You'd also want to add, in your UsersController's beforeFilter a parent::beforeFilter(); i.e.: //Users Controller function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('register', 'login', 'logout'); } On Apr 30, 10:33 am, rgreenphotodesign <rgr...@rgreenphotography.com> wrote: > You need this in all your controllers... > <code> > function beforeFilter() > { > > //actions we allow without authentication, you can also put them > in the app_controller.php > $this->Auth->allow('index'); > > } > </code> > Add all the actions in your controller you want people to have access > to without authentication. > > http://book.cakephp.org/view/247/AuthComponent-Methods > for more info > Russ > > On Apr 30, 5:01 am, DatacenterHellas <merianosni...@gmail.com> wrote: > > > > > Hello all ! ! ! > > > I'm new to CakePHP and I already have create a login system based on > > Auth Component. All are fine with that component, but the problem that > > I have is that if the user logou the system then he can't see any > > page. The Auth redirects automatic to login form. What can I do, for > > desplay pages that are not require login ? ? ? > > > ie : index, about, contact us must be public pages. Do not require > > login. > > add new article, edit articles, manage users must be private. > > > How to select witch page must be private and witch must be public. > > > My Code : > > > AppController : > > > class AppController extends Controller > > { > > var $name = "App"; > > var $helpers = array('javascript','html','form'); > > var $components = array('Auth','newArticle'); > > > function beforeRender() > > { > > $this->set('articles', $this->newArticle->getLatest()); > > } > > > } > > > class UsersController extends AppController > > { > > var $name = "Users"; > > > function beforeFilter() > > { > > $this->Auth->allow('register', 'login', 'logout'); > > } > > > function register() > > { > > if(!empty($this->data)) > > { > > $this->data['User']['password_confirm'] = > > $this->Auth->password > > ($this->data['User']['password_confirm']); > > $this->User->create(); > > if($this->User->save($this->data)) > > { > > > > $this->redirect(array('controller'=>'Pages','action'=>'index')); > > } > > } > > } > > > function login() > > { > > if(!empty($this->data)) > > { > > $usr = $this->Auth->login($this->data); > > if(!empty($usr)) > > { > > $this->set('data',$this->Auth->user()); > > > > $this->redirect(array('controller'=>'Pages','action'=>'index')); > > } > > else > > { > > $this->Session->setFlash("Η είσοδος > > απέτιχε"); > > > > $this->redirect(array('controller'=>'Users','action'=>'login')); > > } > > } > > } > > > function logout() > > { > > $this->Auth->logout(); > > > > $this->redirect(array('controller'=>'Pages','action'=>'index')); > > } > > > } > > > class ArticlesController extends AppController > > { > > var $name = "Articles"; > > var $paginate = array( > > 'limit' => 5, > > 'order' => array( > > 'Article.id' => 'DESC' > > ) > > ); > > > function add() > > { > > if(!empty($this->data)) > > { > > $this->Article->create(); > > > if($this->Article->save($this->data)) > > { > > > > $this->redirect(array('controller'=>'Pages','action'=>'index')); > > } > > else > > { > > $this->Session->setFlash('Σφάλμα κατά την > > αποθήκευση'); > > } > > } > > } > > > function view() > > { > > $artcl = $this->Article->find('first', > > array('conditions'=>array > > ('Article.id'=>$this->params['named']['artid']))); > > $this->set('article', $artcl['Article']); > > } > > > function showAll() > > { > > $artcl = $this->paginate('Article'); > > $this->set('data', $artcl); > > } > > > } > > > class ProfilesController extends AppController > > { > > var $name = "Profiles"; > > > function view() > > { > > $pfl = $this->Profile->find('first', > > array('conditions'=>array > > ('User.id'=>$this->Session->read('Auth.User.id')))); > > $this->set('data', $pfl); > > } > > > function edit() > > { > > if(!empty($this->data)) > > { > > if($this->Profile->save($this->data)) > > { > > > > $this->redirect(array('controller'=>'Profiles','action'=>'view')); > > } > > else > > { > > $this->Session->setFlash('Error'); > > } > > } > > else > > { > > $pfl = $this->Profile->find('first', > > array('conditions'=>array > > ('User.id'=>$this->Session->read('Auth.User.id')))); > > $this->set('data', $pfl); > > } > > } > > > function add() > > { > > if(!empty($this->data)) > > { > > if($this->Profile->save($this->data)) > > { > > > > $this->redirect(array('controller'=>'Profiles','action'=>'view')); > > } > > else > > { > > $this->Session->setFlash('Error'); > > } > > } > > else > > { > > $pfl = $this->Profile->User->find('all', > > array('conditions'=>array > > ('User.id'=>$this->Session->read('Auth.User.id')))); > > $this->set('data', $pfl); > > } > > } > > > } > > > class PagesController extends AppController { > > > var $name = 'Pages'; > > var $uses = null; > > > function index() > > { > > } > > > } > > > class ArticlesController extends AppController > > { > > var $name = "Articles"; > > var $paginate = array( > > 'limit' => 5, > > 'order' => array( > > 'Article.id' => 'DESC' > > ) > > ); > > > function add() > > { > > if(!empty($this->data)) > > { > > $this->Article->create(); > > > if($this->Article->save($this->data)) > > { > > > > $this->redirect(array('controller'=>'Pages','action'=>'index')); > > } > > else > > { > > $this->Session->setFlash('Σφάλμα κατά την > > αποθήκευση'); > > } > > } > > } > > > function view() > > { > > $artcl = $this->Article->find('first', > > array('conditions'=>array > > ('Article.id'=>$this->params['named']['artid']))); > > $this->set('article', $artcl['Article']); > > } > > > function showAll() > > { > > $artcl = $this->paginate('Article'); > > $this->set('data', $artcl); > > } > > > }- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---