I’m new to YII Framework. My past web development work has been using Python frameworks. I’m trying to figure out how to require login for all pages. I have started a new project with the yiic tool. However, on default all pages are accessible. I want the user to be required to login before accessing pages. Thanks in advance.
I’m fairly new too Yii as well, but I’ll give this a shot.
What I think you want to explore is the accesRules function of your controllers for each model. Here you can set rules regarding which actions such as view,update,delete, etc can be viewed by what types of users.
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view','aclist', 'leadlist','countryRate','excel'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
Wow! Thanks! Thank you to all that have responded. Rarely have I received this type of prompt, polite, and informative response from other development tools.
here is what i use. Requre login for all pages …it’s where Rohit Suthar wiki came from… his site has tons of great info. You will probably need to read the comments if you have trouble getting it to work.