Skip to content

Commit

Permalink
fixed access check from submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed May 20, 2020
1 parent a2026eb commit 04b3808
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/traits/AccessBehaviorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public function behaviors()
[
'allow' => true,
'matchCallback' => function ($rule, $action) use ($controller) {
$permission = str_replace('/','_',$controller->module->id . '_' . $controller->id . '_' . $action->id);
// use id including parent modules, if empty (eg. 'app') fall-back to id
$moduleId = empty($controller->module->uniqueId) ? $controller->module->id : $controller->module->uniqueId;
$permission = str_replace('/','_', trim($moduleId,'/') . '_' . $controller->id . '_' . $action->id);
return \Yii::$app->user->can(
$permission,
['route' => true]
Expand All @@ -55,4 +57,4 @@ public function behaviors()
]
);
}
}
}

0 comments on commit 04b3808

Please sign in to comment.