symfony - How does symfony2 redirect to requested page after login -


say route /booking/(.*) protected firewall configuration in security.yml , requires "role_user", when user tries access route preceded "/booking/" app redirects user login page authentication.

so question is, after user provides credentials , gets authenticated, how symfony 2 able redirect user page/route user had requested or symfony 2 store route store in session or else.

can access , how?

this possible , can access referring link (that used if use_referer set true) in session.

for instance, if have success_handler service on form_login (in firewall configuration) redirects users based on criteria (commonly roles) wanted redirect user referrer link if set access referrer link so:

$key = '_security.main.target_path'; #where "main" firewall name  //check if referrer session key has been set  if ($this->container->get('session')->has($key)) {     //set url based on link trying access before being authenticated     $url = $this->container->get('session')->get($key);      //remove session key     $this->container->get('session')->remove($key); } //if referrer key never set, redirect default route else{     $url = $this->router->generate('member_home'); }  return new redirectresponse($url);  

using header referrer (ie $request->headers->get('referer')) not work in case because return login link.

thanks roman marintsenko & ryan weaver blog


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -