Skip to content

Instantly share code, notes, and snippets.

@faizalmansor
Created March 8, 2016 03:00
Show Gist options
  • Save faizalmansor/229e5a802259ba9e3b1e to your computer and use it in GitHub Desktop.
Save faizalmansor/229e5a802259ba9e3b1e to your computer and use it in GitHub Desktop.
Yii2 Access Control to make all actions in controller required login by default
<?php
namespace app\controllers;
use yii\filters\AccessControl;
use yii\web\Controller;
class ExampleController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
public function actionIndex()
{
// Action index
}
}
@deshario
Copy link

There are two symbol that m confused '?' AND '@' ... what it actually means ?

@gh-darvishani
Copy link

? for unknown user and @ for login user
@deshario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment