Search code examples
phpyiiyii-events

delete functionality does not work - Yii


I am building one site in YII. I have made one functionality like delete for one of my controller. I have defined my access rules like this.

public function accessRules()
{
    return array(
        array('allow', // allow authenticated user to perform 'create' and 'update' actions
            'actions'=>array('index', 'create', 'delete', 'update'),
            'users'=>array('*'),
        ),
        array('deny',
            'users' => array('*'),
        ),
    );

}

still If I try to access delete functionality even after login, It gives me this error.

CHttpException

You are not authorized to perform this action. (C:\xampp\htdocs\framework\web\auth\CAccessControlFilter.php:170)

Can anyone tell me what I have done wrong here?


Solution

  •     public function accessRules()
        {
            return array(
                array('allow', // allow authenticated user to perform 'create' and 'update' actions
                    'actions'=>array('index', 'create', 'delete', 'update'),
                    'users'=>array('@'),
                ),
                array('deny',
                    'users' => array('*'),
                ),
            );
    
        }
    Simple Thing you are allowing for all user and also deny for all user then how it will be work now login with demo/demo or admin/admin you can delete