0
In the application there are 2 login forms, one for customers and another for administrators.
The two forms use the same Prior:
security:
providers:
form_login:
entity: { class: FMP\SecurityBundle\Entity\User, property: username }
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
app_secured_area:
pattern: ^/
anonymous: ~
form_login:
provider: form_login
login_path: security_app_login
check_path: security_app_login_check
default_target_path: /
logout:
path: security_logout
target: security_app_login
admin_secured_area:
pattern: ^/admin
anonymous: ~
form_login:
provider: form_login
login_path: security_admin_login
check_path: security_admin_login_check
default_target_path: /admin/
logout:
path: security_logout
target: security_admin_login
default:
anonymous: ~
http_basic: ~
I have the DefaultController.php
structured as follows:
class DefaultController extends Controller
{
/**
* @Route("/login", name="security_app_login")
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function appLoginAction(Request $request)
{
return $this->loginAction($request, 'FMPSecurityBundle:Default:app_login.html.twig');
}
/**
* @Route("/admin/login", name="security_admin_login")
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function adminLoginAction(Request $request)
{
return $this->loginAction($request, 'FMPSecurityBundle:Default:admin_login.html.twig');
}
public function loginAction(Request $request, $template)
{
$session = $request->getSession();
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->render($template, array(
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
}
/**
* @Route("/login_check", name="security_app_login_check")
*/
public function loginCheckAppAction()
{
//
}
/**
* @Route("/admin/login_check", name="security_admin_login_check")
*/
public function loginCheckAdminAction()
{
//
}
/**
* @Route("/logout", name="security_logout")
*/
public function logoutAction()
{
//
}
}
When accessing the route /admin/login
and log in, the following error is returned:
The controller must Return a Response (null Given). Did you Forget to add a Return statement Somewhere in your controller?
What’s wrong? Can’t use the same Preview for different forms?