Merge branch 'master' of https://git.mcnd.ca/mcndave/notes-security
This commit is contained in:
commit
f33fb69150
|
@ -13,7 +13,7 @@ class SecurityHandler {
|
||||||
|
|
||||||
protected ResponseInterface $redirectResponse;
|
protected ResponseInterface $redirectResponse;
|
||||||
|
|
||||||
protected \Closure $unauthorizeResponse;
|
protected ? \Closure $unauthorizeResponse;
|
||||||
|
|
||||||
protected ? Taxus $taxus;
|
protected ? Taxus $taxus;
|
||||||
|
|
||||||
|
@ -36,13 +36,18 @@ class SecurityHandler {
|
||||||
public function taxus(string $className, string $methodName, object $user = null) : ? ResponseInterface
|
public function taxus(string $className, string $methodName, object $user = null) : ? ResponseInterface
|
||||||
{
|
{
|
||||||
if ($taxus = $this->getClassAnnotations(Annotation\Taxus::class, $className, $methodName)) {
|
if ($taxus = $this->getClassAnnotations(Annotation\Taxus::class, $className, $methodName)) {
|
||||||
foreach($taxus as $item) {
|
if ($this->unauthorizeResponse) {
|
||||||
if ( !isset($item->privilege) || $this->taxus->granted($item->privilege, $user, $item) ) {
|
foreach ($taxus as $item) {
|
||||||
return null;
|
if (!isset($item->privilege) || $this->taxus->granted($item->privilege, $user, $item)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return call_user_func_array($this->unauthorizeResponse, [ $user, $taxus, $className, $methodName ] );
|
return call_user_func_array($this->unauthorizeResponse, [ $user, $taxus, $className, $methodName ]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new \ErrorException("Unauthorized response given.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue