Yii Framework Forum

Why the actiondelete can't be called?

(George_lu) #1

Hi, guys!

I am using rbac of yii1.1, when I called the actiondelete, I got a warning such as “You are not authorized to perform this action.”

My accessRule is:

     public function accessRules()
	return array(
		array('allow',  // allow only authenticated users to perform 'index' and 'view' actions
		array('allow', // allow authenticated user to perform 'create' and 'update' actions
		array('allow', // allow admin user to perform 'admin' and 'delete' actions
		array('deny',  // deny all users

And my actiondelete is:

public function actionDelete($id)

	/* var_dump(Yii::app()->user->checkAccess('deleteIssue',$params));exit; */
		throw new CHttpException(403,'You are not authorized to per-form this action');
		// we only allow deletion via POST request

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
			$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
		throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');

But, I can call the updateaction and viewaction exactly. Could you tell me why?

(George_lu) #2

I rewrited the accessRule, and it has been solved.

array(‘allow’, // allow authenticated user to perform ‘create’ and ‘update’ actions