I am not much familiar with Yii, even though i am learning Yii framework. And now i have a problem to view the posts without loged-in. It will automatically redirect to login page. I have clearly added the access rules in my controller. And this is placed under the directory protected/modules/blog. Is this the problem? Modules won’t work without login? i have a lot of doubts like this. And i am not getting any solution for this.
Here is the access rules of my controller file.
public function accessRules()
{
return array(
array('allow', // allow all users to access 'index' and 'view' actions.
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated users to access all actions
'actions'=>array('update','create'),
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
Can anyone help me to find a solution for this issue? if i am wrong in any of the procedures please correct me.
The problem happening between the town page to blog/activity page. While we open the activity page, if we didn’t logged-in, suddenly it will redirect to login page, its url is http://localhost/myapp/user/user/signin, a white-box login form.
And rest of the pages, i didn’t feel the login restriction problem, if its required user login for posting new topic in blog, it will restrict the user to login first and then create a post.
Will this help you to identify the issue? please give your valuable feedback.
to access http://localhost/myapp/blog/activity, you will have to change the access rules of activityController within your blog module. Can you give (copy-paste here) the access rules in activityController.php?
Here is the activity controller class access rules,
class ActivityController extends Controller
{
public $layout='column2';
/**
* @var CActiveRecord the currently loaded data model instance.
*/
private $_model;
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to access 'index' and 'view' actions.
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated users to access all actions
'actions'=>array('update','create'),
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
And here is the town controller class access rules
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'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'),
),
);
}