Last active
February 11, 2016 18:39
-
-
Save giobyte8/ec161cdc28746a84ea3a to your computer and use it in GitHub Desktop.
Autentication example
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 | |
public function behaviors() | |
{ | |
return [ | |
'access' => [ | |
'class' => AccessControl::className(), | |
'rules' => [ | |
array( // Logged users (Admin & Capturista) | |
'actions' => [ | |
'index', | |
'view', | |
'create', | |
'update', | |
'validateajax', | |
], | |
'allow' => ( | |
!Yii::$app->user->isGuest | |
) | |
), | |
array( // Admin user only | |
'actions' => [ | |
'delete' | |
], | |
'allow' => ( | |
!Yii::$app->user->isGuest && | |
Yii::$app->user->identity->isAdmin() | |
) | |
), | |
] | |
], | |
'verbs' => [ | |
'class' => VerbFilter::className(), | |
'actions' => [ | |
'delete' => ['post'], | |
], | |
], | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment