Closed atlet closed 2 years ago
I created custom unauthorizedHandler class and it's working fine.
in config/users.php I added this line:
'Auth.AuthorizationMiddleware.unauthorizedHandler.className' => 'CustomRedirect',
And created a new file CustomRedirectHandler.php in src/Middleware/UnauthorizedHandler directory.
Also I was missing the accept: application/json header.
I created a new application with CakePHP 4. For authentication I used CakeDC/users plugin. It’s working fine. I can login to application.
I also added REST API following this instructions: REST - 4.x
For authentication to API I use Token based and it’s working fine. For API I created a new prefix:
This is config in users.php:
Problem happen when I enter wrong Token. API returns HTML login form. I would like that returns 401.
Is there any good tutorial or any hint, how can solve this issue?
Tnx