Php 在Symfony2中呈现模板而不更改路径

Php 在Symfony2中呈现模板而不更改路径,php,symfony,Php,Symfony,我制作了一个登录函数,在这个函数中,我在检查登录名和密码后呈现一个模板。这是我在模板中制作的表单 <form action="{{ path("login") }}" method="post" id="formulaire_connexion"> <label class="control-label">Email <input type="text" name="email" id="email" placeholder="your@email.com"

我制作了一个登录函数,在这个函数中,我在检查登录名和密码后呈现一个模板。这是我在模板中制作的表单

<form action="{{ path("login") }}" method="post" id="formulaire_connexion">
 <label class="control-label">Email
 <input  type="text" name="email" id="email" placeholder="your@email.com" onclick="this.select()"/>
  </label>
   <label class="control-label">Password</br>
   <input  type="password" name="password" id="password" placeholder="*********" onclick="this.select()"/>
   </label>
   <input type="checkbox" id="remember_me" name="remember_me"><label for="remember_me">Remember me </label></br>
   <button type="submit" id="connexion" name="connexion">Connexion</button>
   </form>

在错误的登录连接之后,我呈现了相同的登录模板,但是路由更改为/login,而不是havig/index。我需要知道的是,即使我们调用了一个外部方法,如何保持相同的路由。

这是因为表单的操作是“/login”,因此如果auth失败,您可以检查refferer并重定向回,请检查此帖子侧注:一个好的做法是,永远不要在post请求时呈现某些内容,始终重定向到GET。
public function loginAction(Request $request)
{
    $mail = $request->get('email');
    $pass = $request->get('password');
    $oauth = new OAuth($mail, $pass);

    $baseUrl = "http://api.localhost/v1/";
    $connexion = "{$baseUrl}login/".$mail."/".$pass;

    $oauth->fetch($connexion, $_REQUEST, OAUTH_HTTP_METHOD_GET);

    $reponseInformations = json_decode($oauth->getLastResponse(), true);


    if (!$reponseInformations) {

        $data['erreur'] = "Bad credentials";

        return $this->render('EspacePointDeVenteBundle:Authentication:authentication.html.twig', array(
            'erreur' => $data,
        ));

    }else{
        return $this->render('EspacePointDeVenteBundle:Home:index.html.twig', array(
            'reseau' => $reseau,
            'identifiant' => $key,
            'key' => $identifiant,
        ));
    }

}