Created
March 8, 2016 03:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} | |
} |
Very GOOOOOD
There are two symbol that m confused '?' AND '@' ... what it actually means ?
? 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
yes it is!!