Hello everybody,
This is my behaviors function in backend/SiteController , i am using User::isUserAdmin($param,$param) function for checking if logged user has admin role or not. Now i got 403 error page, when i try to access the index function with normal user without admin role. How can i set a return url to login page, when this function User::isUserAdmin($param,$param) return false value.
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'index'],
'rules' => [
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
[
'actions' => ['index'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return User::isUserAdmin(Yii::$app->user->identity->username);
},
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}