I have two tables in this project of mine. One table is for the site admin which stores all the admin users details, and the other table stores all the login data for clients to the site.
At the moment, I can log in using the admin details fine. However, I am now trying to login with the client details and it doesn't seem to be working. So far, when a user clicks on a link it will go to /clientarea/login. This page loads up fine. But when I try to log in I get an error.
The error I am getting is this:
Unable to find the controller for path "/clientarea/login_check". Maybe you forgot to add the matching route in your routing configuration?
In my security.yml file, I have the following code: (By the way, I'm using plaintext for development only, it will be changed when it goes live):
providers:
admin_db:
entity: { class: Shout\AdminBundle\Entity\User, property: username }
client_db:
entity: { class: Shout\AdminBundle\Entity\Userclients, property: username }
encoders:
Shout\AdminBundle\Entity\User:
algorithm: plaintext
Shout\AdminBundle\Entity\Userclients:
algorithm: plaintext
firewalls:
secured_area:
pattern: ^/
anonymous: ~
provider: admin_db
form_login:
check_path: /login_check
login_path: /login
logout:
path: /logout
target: /index
client_area:
pattern: ^/
anonymous: ~
provider: client_db
form_login:
check_path: /clientarea/login_check
login_path: /clientarea/login
logout:
path: /clientarea/logout
target: /index
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/clientarea/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/clientarea, roles: ROLE_USER }
In my routing.yml I have this code:
login:
pattern: /login
defaults: { _controller: ShoutAdminBundle:Security:login }
login_check:
pattern: /login_check
logout:
pattern: /logout
clientlogin:
pattern: /clientarea/login
defaults: { _controller: ShoutAdminBundle:Security:clientlogin }
clientlogin_check:
pattern: /clientarea/login_check
clientlogout:
pattern: /clientarea/logout
Here is the code in the controller. The code is identical for the login and clientlogin functions, the only thing that is different is the twig file they point to:
$request = $this->getRequest();
$session = $request->getSession();
// get the login error if there is one
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render('ShoutAdminBundle:Security:clientlogin.html.twig', array(
// last username entered by the user
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
The action path of the Client Login form points to clientlogin_check.
What am I doing wrong?