In my symfony project, I would like to use authentification. So I wrote this in my security.yml file
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
default:
anonymous: ~
login_firewall:
pattern: ^/login$
anonymous: ~
secured_area:
pattern: ^/
anonymous: ~
form_login:
login_path: /login
check_path: /login_check
post_only: true
always_use_default_target_path: true
default_target_path: /
use_referer: false
username_parameter: username
password_parameter: password
intention: authenticate
logout:
path: /logout
target: /
Ok, now documentation says that I need to add in routing.yml this :
login:
pattern: /login
defaults: { _controller: AcmeSecurityBundle:Security:login }
login_check:
pattern: /login_check
But I am using annotation, so I don't use routing files. Instead I have this :
/**
* @Route("/login")
* @Template()
*/
public function loginAction()
{
$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);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
}
return array(
// last username entered by the user
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
);
}
If I do nothing, I have an error in my login page :
"Unable to generate a URL for the named route "login_check" as such route does not exist."
If I add an action in my controller with an empty response, there is... nothing.
What am I doing wrong ?