Skip to content

Instantly share code, notes, and snippets.

@giobyte8
Last active Feb 11, 2016
Embed
What would you like to do?
Autentication example
<?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