I install symfony CMF. When i want to login as admin I get this error:
Unable to find the controller for path "/demo/login_check". The route is wrongly configured.
codes of cmf/src/Acme/DemoBundle/Resources/config/routing.yml
_demo_security:
resource: "@AcmeDemoBundle/Controller/SecurityController.php"
type: annotation
_demo_login_check:
path: /login_check
_demo_logout:
path: /logout
codes of SecurityController
:
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class SecurityController extends Controller
{
/**
* @Route("/login", name="_demo_login")
* @Template
*/
public function loginAction(Request $request)
{
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
return array(
'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
'error' => $error,
);
}
}
security controller don't have an action for login_check
.
In most cases symfony automatically handles the login through it's authentication listeners. So basically a form login authentication listener will handle your login when you post to
/domo/login_check
route. But you will have configure these things to work in the firewall section of yoursecurity.yml
file inapp/config/security.yml
. Below is a demo file I use.so as you can see under the firewall section I have configured three firewals,
dev
,default
,admin_restricted_area
.so if you look at the
default
firewall , I am telling symfony to use theform_login
authentication listener to handle login form display and login check. So in your case it will beNow the provider section is telling symfony to use my own user provider which of cause must implement their
Symfony\Component\Security\Core\User\UserProviderInterface
So you do not have to write an action for the login check route. Symfony intercept your
_demo_login_check
and process it automatically