- Secured the unauthorized route if nothing was provided
This commit is contained in:
parent
b506bae846
commit
532cecfcad
|
@ -13,7 +13,7 @@ class SecurityHandler {
|
|||
|
||||
protected ResponseInterface $redirectResponse;
|
||||
|
||||
protected \Closure $unauthorizeResponse;
|
||||
protected ? \Closure $unauthorizeResponse;
|
||||
|
||||
protected ? Taxus $taxus;
|
||||
|
||||
|
@ -36,6 +36,7 @@ class SecurityHandler {
|
|||
public function taxus(string $className, string $methodName, object $user = null) : ? ResponseInterface
|
||||
{
|
||||
if ($taxus = $this->getClassAnnotations(Annotation\Taxus::class, $className, $methodName)) {
|
||||
if ($this->unauthorizeResponse) {
|
||||
foreach ($taxus as $item) {
|
||||
if (!isset($item->privilege) || $this->taxus->granted($item->privilege, $user, $item)) {
|
||||
return null;
|
||||
|
@ -44,6 +45,10 @@ class SecurityHandler {
|
|||
|
||||
return call_user_func_array($this->unauthorizeResponse, [ $user, $taxus, $className, $methodName ]);
|
||||
}
|
||||
else {
|
||||
throw new \ErrorException("Unauthorized response given.");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue