add role checking to controllers
This commit is contained in:
@@ -6,6 +6,7 @@ use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Account;
|
||||
use common\components\RoleDefinition;
|
||||
|
||||
/**
|
||||
* AccountSearch represents the model behind the search form about `common\models\Account`.
|
||||
@@ -43,6 +44,12 @@ class AccountSearch extends Account
|
||||
{
|
||||
$query = Account::find();
|
||||
|
||||
|
||||
if ( !RoleDefinition::isAdmin() ){
|
||||
$query->innerJoin("user_account_assignment",'account.id_account = user_account_assignment.id_account' );
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user