No route found for "GET /"
Salut
J'ai essayé de faire un script de connexion mais une erreur s'affiche après la connexion :
No route found for "GET /"
voici le code :
Security.yml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
anonymous: true
provider: in_memory
form_login:
login_path: login
check_path: login_check
logout:
path: logout
target: /store |
routing.yml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
store_sous_categorie:
resource: "@StoreCategorieBundle/Resources/config/routing-sous-categorie.yml"
prefix: /sous-categorie
store_categorie:
resource: "@StoreCategorieBundle/Resources/config/routing.yml"
prefix: /categorie
store_produit:
resource: "@StoreProduitBundle/Resources/config/routing.yml"
prefix: /store
login:
pattern: /store/login
defaults: { _controller: StoreUserBundle:Security:login }
login_check:
pattern: /store/login_check
logout:
pattern: /store/logout |
SecurityController.php
Code:
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
|
<?php
namespace Store\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContext;
class SecurityController extends Controller
{
public function loginAction()
{
// Si le visiteur est déjà identifié, on le redirige vers l'accueil
if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED'))
{
return $this->redirect($this->generateUrl('store_produit_index'));
}
$request = $this->getRequest();
$session = $request->getSession();
// On vérifie s'il y a des erreurs d'une précédente soumission du formulaire
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 $this->render('StoreUserBundle:Security:login.html.twig',
array(
// Valeur du précédent nom d'utilisateur entré par l'internaute
'last_username' => $session->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
}
}
?> |
login.html.twig
Code:
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
|
{# src/Store/UserBundle/Resources/views/Security/login.html.twig #}
{% extends "::layoutStore.html.twig" %}
{% block body %}
{# S'il y a une erreur, on l'affiche dans un joli cadre #}
{% if error %}
<div class="alert alert-error">{{ error.message }}</div>
{% endif %}
{# Le formulaire, avec URL de soumission vers la route «login_check » comme on l'a vu #}
<form action="{{ path('login_check') }}" method="post">
<label for="username">Login :</label>
<input type="text" id="username" name="_username" value="{{last_username }}" />
<label for="password">Mot de passe :</label>
<input type="password" id="password" name="_password">
<br/>
<input type="submit" value="Connexion" />
</form>
{% endblock %} |
aprés la connexion , il me dirige vers http://localhost/symfony2/web/app_dev.php/ au lieux de http://localhost/symfony2/web/app_dev.php/store/ et il m'affiche l'erreur suivant :
No route found for "GET /"
404 Not Found - NotFoundHttpException
1 linked Exception:
ResourceNotFoundException »
pouvez-vous m'aider s'il vous plaît ?
merci d'avance.