Authorization Exception

Hi there, I’m trying to redirect unauthorized actions to ‘/users/login’ URL but I get CakePHP error page instead.
Screenshot (32)

Hello sir,

Is a bit weird to redirect to login page while your are connected. Resolve your conflict for redirect on a page that the user is allow to go connected.

‘users/login’ its just to test how redirecting unauthorized action plays out same as ‘articles/index’, still waiting for your help on the issue.

Have you got use Authorization\Exception\ForbiddenException; at the top of your Application.php file?

Yes :point_down:

@Lamine you have a small typo in your config. It should be exceptions not exception.

So like

'unauthorizedHandler' => [
    'className' => 'Authorization.Redirect',
    'url' => '/users',
    'queryParam' => 'redirectUrl',
    'exceptions' => [
        MissingIdentityException::class,
        ForbiddenException::class
    ]
]

Then your redirect should work.

It working now, thanks.