Skip to content

Instantly share code, notes, and snippets.

@giobyte8
Last active February 11, 2016 18:39
Show Gist options
  • Save giobyte8/ec161cdc28746a84ea3a to your computer and use it in GitHub Desktop.
Save giobyte8/ec161cdc28746a84ea3a to your computer and use it in GitHub Desktop.
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