Commit e64e35fb by Luciano Baraglia

Authorization doc match callback example

parent 701852e9
......@@ -57,10 +57,10 @@ class SiteController extends Controller
return [
'access' => [
'class' => \yii\web\AccessControl::className(),
'only' => ['special'],
'only' => ['special-callback'],
'rules' => [
[
'actions' => ['special'],
'actions' => ['special-callback'],
'allow' => true,
'matchCallback' => function ($rule, $action) {
return date('d-m') === '31-10';
......@@ -68,6 +68,17 @@ class SiteController extends Controller
],
```
And the action:
```php
// ...
// Match callback called! This page can be accessed only each October 31st
public function actionSpecialCallback()
{
return $this->render('happy-halloween');
}
```
Sometimes you want a custom action to be taken when access is denied. In this case you can specify `denyCallback`.
Role based access control (RBAC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment