Merge pull request #81 from kartik-v/patch-1

Update AccessRuleFilter to evaluate roleParams
This commit is contained in:
Antonio Ramirez
2017-10-15 13:34:14 +02:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# CHANGELOG
## 1.0.14 - Work in progress
- Enh #81: Update `AccessRuleFilter` to evaluate `roleParams` (kartik-v)
- Enh #56: Added two factor authentication (tonydspaniard)
- Fix #63: Fix selectize version (tonydspaniard)
- Enh #65: Updated Romanian translation (mrbig00)

View File

@ -11,6 +11,7 @@
namespace Da\User\Filter;
use Closure;
use Da\User\Model\User;
use yii\filters\AccessRule;
@ -41,8 +42,13 @@ class AccessRuleFilter extends AccessRule
if (!$user->getIsGuest() && $identity->getIsAdmin()) {
return true;
}
} elseif ($user->can($role)) {
return true;
} else {
if (!isset($roleParams)) {
$roleParams = $this->roleParams instanceof Closure ? call_user_func($this->roleParams, $this) : $this->roleParams;
}
if ($user->can($role, $roleParams)) {
return true;
}
}
}