Access Rules Not Working

This is my access rules which is not working

Controller


public function filters()

    {

        return array('accessControl');

    }


public function accessRules()

	{

		return array(

	        array('allow',  // allow all users to perform these actions

	            'actions'=>array('index','error','login','signup','trial','success','activate','resetPassword','pages'),

	            'users'=>array('*'),

	        ),

	        array('allow', // allow authenticate users to perform these actions

	            'actions'=>array('logout'),

	            'users'=>array('@'),

	        ),

	        array('deny',  // deny all users anything not specified

	            'users'=>array('*'),

	        ),

	    );

	}

Main.php


'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'loginUrl' => array('user/index'),

		),

any ideas…

Friends, please help its very urgent

What exacltly not working?

On every action, the application redirects me to the url I mentioned in the main.php i.e, user/index

Like: after getting log-in to the application, when I click on the logout link, it redirects me to the localhost/appname/index.php/user/index

what do you want to achieve?

seems you don’t need any access rules as long as ‘users’=>array(’*’)

you’d beter remove rules in this case.




'user'=>array(

            # encrypting method (php hash function)

            'hash' => 'md5',

            # send activation email

            'sendActivationMail' => false,

            # allow access for non-activated users

            'loginNotActiv' => false,

            # activate user on registration (only sendActivationMail = false)

            'activeAfterRegister' => false,

            # automatically login from registration

            'autoLogin' => true,

            # registration path

            'registrationUrl' => array('/user/registration'),

            # recovery password path

            'recoveryUrl' => array('/user/recovery'),

            # login form path

            'loginUrl' => array('/user/login'),

            # page after login

            'returnUrl' => array('/user/profile'),

            # page after logout

            'returnLogoutUrl' => array('/user/login'),

        ),



I want to restrict the guest user to access the different actions defined in different controller.

When I am applying the access rules like:




public function accessRules() {

		return array(

			array('allow', // allow authenticated user actions

				'actions'=>array('index','edit'),

				'users'=>array('@'),

			),

                        array('allow', // allow all user

				'actions'=>array('passwordSetting','roomSetting'),

				'users'=>array('*'),

			),

                        array('deny',  // deny all users anything not specified

                              'users'=>array('*'),

                       ),

		);

	}



When I remove the deny column the rules are applying to both guest and logged in users.

When I apply it, none of the rules are working




/**

* @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

			'users'=>array('@'),

		),

		array('deny',  // deny all users

			'users'=>array('*'),

		),

	);

}



I tried all these options but still access rules are creating problem. Please tell me the complete logic to apply the access rules.

the easiest way is to generate all you need with gii/giix.

as far as i can see you use module "user" so you need to install it proper first.