making the home page require Auth (CakePHP)
I just started开发者_如何转开发 to learn CakePHP and i'm trying to make the homepage (views\pages\home.ctp) only available to logged users, so if an unlogged users enter to the homepage they should be redirected to Users controller, where it prompts for user data, using Auth Component.
Where I can set the "controller" for the homepage? please correct me if i'm using the wrong terms :)
Thanks
this is normally done with the authorization component and a beforeFilter in the app controller.
here's a good example:
http://www.milesj.me/blog/read/5/Using-CakePHPs-Auth-Component
you will face with the next problem....now if you add beforeFilter in any of your controllers, you will find out that the main beforeFilter doesnot work...don't forget about this
<?php
class ArticlesController extends AppController
{
function beforeFilter(){
parent::beforeFilter();
}
}?>
精彩评论