Hi together,
I created a page where user can login.
This was done by using cakephp Authentication and Authorization. All works fine.
I did it like it is described in tutorial.
And now I added an admin area by using prefix for admin in routes.
But when I try to login right now in Admin area, I get an error
'Login URL `/project/admin/users/login` did not match `/project/users/login`.',
In Application.php I add a function getAuthenticationService (like described in tutorial).
And here I have the unauthenticatedRedirect and loginUrl
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
{
$authenticationService = new AuthenticationService([
'unauthenticatedRedirect' => Router::url('/users/login'),
'queryParam' => 'redirect',
]);
// Load identifiers, ensure we check email and password fields
$authenticationService->loadIdentifier('Authentication.Password', [
'fields' => [
'username' => 'email',
'password' => 'password',
],
]);
// Load the authenticators, you want session first
$authenticationService->loadAuthenticator('Authentication.Session');
// Configure form data check to pick email and password
$authenticationService->loadAuthenticator('Authentication.Form', [
'fields' => [
'username' => 'email',
'password' => 'password',
],
'loginUrl' => Router::url('/users/login'),
]);
return $authenticationService;
}
Both URLS are showing to the frontend login but not on admin login.
Do I need to create a separate function for Backend? If yes, where should I put it?
And what is about the policies. Do I also have to create some in aditional for Admin?
Maybe someone knows