- Unauthorize response now allows ResponseInterface as type
This commit is contained in:
parent
63c7dc23f9
commit
e20157a162
@ -14,11 +14,11 @@ class SecurityHandler {
|
|||||||
|
|
||||||
protected ResponseInterface $redirectResponse;
|
protected ResponseInterface $redirectResponse;
|
||||||
|
|
||||||
protected ? \Closure $unauthorizeResponse;
|
protected \Closure|ResponseInterface|null $unauthorizeResponse;
|
||||||
|
|
||||||
protected ? Taxus $taxus;
|
protected ? Taxus $taxus;
|
||||||
|
|
||||||
public function __construct(ResponseInterface $redirectResponse, ? \Closure $unauthorizeResponse = null, ? Taxus $taxus = null) {
|
public function __construct(ResponseInterface $redirectResponse, \Closure|ResponseInterface|null $unauthorizeResponse = null, ? Taxus $taxus = null) {
|
||||||
$this->redirectResponse = $redirectResponse;
|
$this->redirectResponse = $redirectResponse;
|
||||||
$this->unauthorizeResponse = $unauthorizeResponse;
|
$this->unauthorizeResponse = $unauthorizeResponse;
|
||||||
$this->taxus = $taxus;
|
$this->taxus = $taxus;
|
||||||
@ -51,6 +51,10 @@ class SecurityHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->unauthorizeResponse) {
|
if ($this->unauthorizeResponse) {
|
||||||
|
if ($this->unauthorizeResponse instanceof ResponseInterface) {
|
||||||
|
return $this->unauthorizeResponse;
|
||||||
|
}
|
||||||
|
|
||||||
return call_user_func_array($this->unauthorizeResponse, [ $user, ['method' => $fromMethod, 'object' => $fromObject ], $className, $methodName ]);
|
return call_user_func_array($this->unauthorizeResponse, [ $user, ['method' => $fromMethod, 'object' => $fromObject ], $className, $methodName ]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user