Yii :: app() - > user-> setFlash Access在控制器中被拒绝

时间:2015-05-17 14:22:28

标签: php yii

我在控制器中尝试这个:

Yii::app()->user->setFlash('success', "message to user.");

但是我收到了这个错误:

[exception.CHttpException.403] exception 'CHttpException' with message 
'You do not have access to do this action.'
in /yii/framework/web/auth/CAccessControlFilter.php:182
Stack trace:
 /yii/framework/web/auth/CAccessControlFilter.php(145):
   CAccessControlFilter->accessDenied(Object(WebUser)

 /home/iteb/yii/framework/web/filters/CFilter.php(38): 
   CAccessControlFilter->preFilter(Object(CFilterChain))
 ...     

控制器代码:

<?php
class UserReportController extends Controller {
public function filters() {
    return array(
        'accessControl', 
    );
}

public function accessRules() {
    return array(
        array('allow', 
            'actions' => array('create'),
            'users' => array('*'),
        ),
    );
}

public function actionCreate() {
    $model = new UserReport;
    if (isset($_POST['UserReport'])) {
         $model->attributes = $_POST['UserReport'];
         if ($model->save()) {
                Yii::app()->user->setFlash('success', "saved!");

        }
    }

}

}

我不知道该怎么做。

0 个答案:

没有答案