1

I'm new in symfony and I'm following the login form tutorial(https://symfony.com/doc/2.8/cookbook/security/form_login_setup.html) but I get the following error:

Uncaught PHP Exception LogicException: "The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller?" at /var/www/html/app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 157
Context: { "exception": "Object(LogicException)" }

I use the same SecurityController:

class SecurityController extends Controller{


 * @Route("/admin", name="login")

public function loginAction(Request $request)
{

 $authenticationUtils = $this->get('security.authentication_utils');

// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();

// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();

return $this->render(
    'security/login.html.twig',
    array(
        // last username entered by the user
        'last_username' => $lastUsername,
        'error'         => $error,
    )
);
}

/**
 * @Route("/login_check", name="login_check")
 */
public function loginCheckAction()
{
    // this controller will not be executed,
    // as the route is handled by the Security system
}

security.yml

# To get started with security, check out the documentation:

http://symfony.com/doc/current/book/security.html

security:

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
    app_users:
         ldap:
             service: app.ldap
             base_dn: DC=corp, DC=int
             search_dn: null
             search_password: null
             filter: (uid={username})
             default_roles: ROLE_USER

firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    main:
        anonymous: ~
        # activate different ways to authenticate

        # http_basic: ~
        # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate

        # form_login: ~
        # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
    secure:
        provider: app_users
        form_login_ldap:
            service: app.ldap
            dn_string: "uid={username},ou=Users,dc=corp,dc=int"
            check_path: login_check
            login_path: admin
        logout: true
1
  • What does your security config look like? (app/config/security.yml) Commented Jan 31, 2016 at 10:55

1 Answer 1

0

In your security.yml, try to replace

check_path: login_check

by

check_path: /login_check

And make your method like this :

/**
 * @Route("/login_check", name="login_check")
 */
public function loginCheckAction()
{
    throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.