# |
Jul 23rd 2021, 13:18 |
kevin.pfeifer |
check your middleware |
# |
Jul 23rd 2021, 13:18 |
paolo.bragagni |
*Identity is not authorized to perform `add` on `App\Model\Entity\Libro`.* |
# |
Jul 23rd 2021, 13:18 |
paolo.bragagni |
but it doesnt redirect |
# |
Jul 23rd 2021, 13:17 |
kevin.pfeifer |
ok sure |
# |
Jul 23rd 2021, 13:17 |
paolo.bragagni |
no. now I've copied all redirect handler to my handler |
# |
Jul 23rd 2021, 13:17 |
kevin.pfeifer |
``` // Add authorization **after** authentication ->add(new AuthorizationMiddleware($this, [ 'unauthorizedHandler' => [ 'className' => 'CustomRedirect', 'url' => '/users/login', 'queryParam' => 'redirectUrl', 'exceptions' => [ MissingIdentityException::class, ForbiddenException::class ], ], ]))``` |
# |
Jul 23rd 2021, 13:15 |
kevin.pfeifer |
so its not working for you? |
# |
Jul 23rd 2021, 13:14 |
kevin.pfeifer |
basically what is done here https://github.com/cakephp/authorization/blob/master/src/Middleware/UnauthorizedHandler/RedirectHandler.php#L61 |
# |
Jul 23rd 2021, 13:14 |
paolo.bragagni |
a little bit too much for me :S |
# |
Jul 23rd 2021, 13:13 |
kevin.pfeifer |
and you have to tell the handler which exceptions it should “listen” to |
# |
Jul 23rd 2021, 13:13 |
kevin.pfeifer |
the handler only redirects certain exceptions |
# |
Jul 23rd 2021, 13:10 |
kevin.pfeifer |
and `use Authorization\Exception\ForbiddenException;` at the top |
# |
Jul 23rd 2021, 13:10 |
kevin.pfeifer |
you need to add `ForbiddenException::class` to the `exception` array |
# |
Jul 23rd 2021, 13:09 |
kevin.pfeifer |
as said, thats a different exception |
# |
Jul 23rd 2021, 13:08 |
paolo.bragagni |
*Identity is not authorized to perform `add` on `App\Model\Entity\Libro`* |
# |
Jul 23rd 2021, 13:05 |
kevin.pfeifer |
depending on the thrown execption could be that you need to adjust the expections array in the config |
# |
Jul 23rd 2021, 13:05 |
kevin.pfeifer |
works for me now :thinking_face: |
# |
Jul 23rd 2021, 13:04 |
paolo.bragagni |
mmm |
# |
Jul 23rd 2021, 13:04 |
kevin.pfeifer |
try to just return false to test it |
# |
Jul 23rd 2021, 13:04 |
kevin.pfeifer |
thats a problem inside your policy |
# |
Jul 23rd 2021, 13:00 |
paolo.bragagni |
*Pre-authorization check must return `Authorization\Policy\ResultInterface`, `bool` or `null`.* |
# |
Jul 23rd 2021, 12:56 |
kevin.pfeifer |
well i basically copied my values from the use statement but i forgot that you need to add the \ if youre not using the class via the use |
# |
Jul 23rd 2021, 12:54 |
paolo.bragagni |
before Authorization |
# |
Jul 23rd 2021, 12:52 |
kevin.pfeifer |
could be that i forgot the \ at the front of App ,:) |
# |
Jul 23rd 2021, 12:51 |
paolo.bragagni |
*Interface 'App\Middleware\UnauthorizedHandler\Authorization\Middleware\UnauthorizedHandler\HandlerInterface' not found* |
# |
Jul 23rd 2021, 12:49 |
kevin.pfeifer |
basically i forgot the extend of the already present RedirectHandler |
# |
Jul 23rd 2021, 12:49 |
kevin.pfeifer |
check again, should be more clear now |
# |
Jul 23rd 2021, 12:44 |
paolo.bragagni |
fighting with namespaces |
# |
Jul 23rd 2021, 12:39 |
kevin.pfeifer |
i mixed 2 things together, let me fix that |
# |
Jul 23rd 2021, 12:39 |
kevin.pfeifer |
ah sorry, i forgot something |
# |
Jul 23rd 2021, 12:37 |
paolo.bragagni |
wait |
# |
Jul 23rd 2021, 12:37 |
paolo.bragagni |
I'm stupid |
# |
Jul 23rd 2021, 12:37 |
paolo.bragagni |
:S |
# |
Jul 23rd 2021, 12:37 |
paolo.bragagni |
*Handler `Regtosc` does not exist.* |
# |
Jul 23rd 2021, 12:32 |
paolo.bragagni |
thank you Kevin. trying to reproduce |
# |
Jul 23rd 2021, 12:32 |
kevin.pfeifer |
you can check out https://github.com/LordSimal/authorization/blob/master/docs/en/middleware.rst#how-to-create-a-custom-unauthorizedhandler till we wait till my PR is being reviewed |
# |
Jul 23rd 2021, 12:31 |
kevin.pfeifer |
well since you will be implementing a custom handler you can do that logic in there too |
# |
Jul 23rd 2021, 12:11 |
paolo.bragagni |
also redirection to previuos page needs an handler? |
# |
Jul 23rd 2021, 12:10 |
paolo.bragagni |
hhihi thanks (I think that its a common request, so probably should be included someway in default code) |
# |
Jul 23rd 2021, 12:08 |
kevin.pfeifer |
I am just in the process of updating the doc since its a bit more “advanced” I would say |
# |
Jul 23rd 2021, 12:06 |
paolo.bragagni |
first of all I dont know how to create my own handler |