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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
? for unknown user and @ for login user
@deshario