Open devswaam opened 10 years ago
what is your URL for the login check page ?
hitting this URL http://localhost/site/web/app_dev.php/login and it takes me to http://localhost/patient/web/app_dev.php/login_check and shows that error. don't know whats wrong, i am new to symfony as well.
On Thu, Jul 17, 2014 at 5:05 AM, Christophe Coevoet < notifications@github.com> wrote:
what is your URL for the login check page ?
— Reply to this email directly or view it on GitHub https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1538#issuecomment-49298101 .
why going from /site to /patient ?
sorry for typo its http://localhost/siteweb/app_dev.php/login_check
On Thu, Jul 17, 2014 at 5:58 AM, Christophe Coevoet < notifications@github.com> wrote:
why going from /site to /patient ?
— Reply to this email directly or view it on GitHub https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1538#issuecomment-49302817 .
same issue any guide?
Hi, i have updated SF 2.4 to SF 2.8 and Updated FOSUserBundle 1.3 to 2.0 version Below attachment is my security.yml file
Showing below RunTimeException
It was working fine with my SF2.4 version.
I may have missed something, please help.
@allabakash If you use the value _fos_user_securitycheck you are calling to SecurityController.php class and invoking the checkAction() method which exactly only throws an RuntimeError Exception with the error displayed "You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.". So the fix is so simple that not use the value fos_user_security_check and implement your authentication listener.
So @stof the users are not fully understanding that they don't have to use the default SecurityController::checkAction() for this and they have to especify another with an authentication listener.
Thanks for your reply, Still the same, without fos_user_security_check. Security.yml
now it's pointing to RuntimeException: You must configure the check path to be handled by the firewall using form_login in your security firewall configuration. in /var/www/html/Soundbasics_production/SoundBasics_Symfony/vendor/friendsofsymfony/user-bundle/Controller/SecurityController.php on line 78 @stof @shakaran do i have to implement authentication listener.
@allabakash after change that, you need implement a authentication listener, for example:
I have this under src/MyAppBundle/EventListener/AuthenticationListener.php
<?php
/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\UserBundle\EventListener;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Security\LoginManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
class AuthenticationListener implements EventSubscriberInterface
{
/**
* @var LoginManagerInterface
*/
private $loginManager;
/**
* @var string
*/
private $firewallName;
/**
* AuthenticationListener constructor.
*
* @param LoginManagerInterface $loginManager
* @param string $firewallName
*/
public function __construct(LoginManagerInterface $loginManager, $firewallName)
{
$this->loginManager = $loginManager;
$this->firewallName = $firewallName;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::REGISTRATION_COMPLETED => 'authenticate',
FOSUserEvents::REGISTRATION_CONFIRMED => 'authenticate',
FOSUserEvents::RESETTING_RESET_COMPLETED => 'authenticate',
);
}
/**
* @param FilterUserResponseEvent $event
* @param string $eventName
* @param EventDispatcherInterface $eventDispatcher
*/
public function authenticate(FilterUserResponseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
try {
$this->loginManager->logInUser($this->firewallName, $event->getUser(), $event->getResponse());
$eventDispatcher->dispatch(FOSUserEvents::SECURITY_IMPLICIT_LOGIN, new UserEvent($event->getUser(), $event->getRequest()));
} catch (AccountStatusException $ex) {
// We simply do not authenticate users which do not pass the user
// checker (not enabled, expired, etc.).
}
}
}
In services.yml:
services:
account.security_listener:
class: %account.security_listener.class%
arguments: ['@security.authorization_checker', '@session'] # security.context (deprecated) or 'security.token_storage
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin
Then as src/MyAppBundle/Controller/SecurityController.php:
<?php
namespace MyAppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class SecurityController extends Controller
{
public function loginAction(Request $request)
{
/** @var $session Session */
$session = $request->getSession();
$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();
$csrfToken = $this->has('security.csrf.token_manager')
? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue()
: null;
$authChecker = $this->get('security.authorization_checker');
$router = $this->get('router');
return $this->render(
'FOSUserBundle:Security:login.html.twig',
[
// last username entered by the user
'last_username' => $lastUsername,
'error' => $error,
'csrf_token' => $csrfToken,
]
);
}
}
@shakaran , May I know, which FOSUserBundle version, you are referring to,
I'm using SF 2.8, FOSUserBundle ~2.0 version.
No luck
@allabakash I am using Symfony 3.3 and dev-master of FOSUserBundle
After creating user and login , i got this error You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.
searched to solve this but couldn't not. help please... here is my security.yml file
here is routing.yml