Bonjour,
J'ai installé le bundle fosuser jusqu a mnt ca va mais mon probleme c'est que je me rediriger vers ma page inscription sans passer page la page authentification voila le code que j'ai ajouté pour la redirection vers la page inscription.
return $this->container->get('templating')->renderResponse('MyAppUtilisateurBundle:Default:inscription.html.twig');
voila le code de la page securitycontroller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| <?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 MyApp\UtilisateurBundle\Controller;
use MyApp\UtilisateurBundle\MyAppUtilisateurBundle;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Entity\User as User;
use FOS\UserBundle\Controller\SecurityController as BaseSecurity;
class SecurityController extends BaseSecurity
{
public function loginAction()
{
$request = $this->container->get('request');
/* @var $request \Symfony\Component\HttpFoundation\Request */
$session = $request->getSession();
/* @var $session \Symfony\Component\HttpFoundation\Session */
//if user is logged, redirect to homepage
$user = $this->container->get('security.context')->getToken()->getUser();
return $this->container->get('templating')->renderResponse('MyAppUtilisateurBundle:Default:inscription.html.twig');
if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} elseif (null !== $session && $session->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
$session->remove(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = '';
//return $this->container->get('templating')->renderResponse('MyAppUtilisateurBundle:Default:inscription.html.twig');
}
if ($error) {
// TODO: this is a potential security risk (see http://trac.symfony-project.org/ticket/9523)
$error = $error->getMessage();
}
// last username entered by the user
$lastUsername = (null === $session) ? '' : $session->get(SecurityContext::LAST_USERNAME);
$csrfToken = $this->container->get('form.csrf_provider')->generateCsrfToken('authenticate');
return $this->container->get('templating')->renderResponse('FOSUserBundle:Security:login.html.'.$this->container->getParameter('fos_user.template.engine'), array(
'last_username' => $lastUsername,
'error' => $error,
'csrf_token' => $csrfToken,
));
}
public function checkAction()
{
/*$user = $this->container->get('security.context')->getToken()->getUser();
if (is_object($user) && $user instanceof User)
{
return $this->container->get('templating')->renderResponse('MyAppUtilisateurBundle:Default:inscription.html.twig');
}
//return $this->render('MyAppUtilisateurBundle:Default:connexion.html.twig');*/
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}
public function logoutAction()
{
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
}
} |
Merci d'avance
Partager