Is there a way to get the url that was redirected to login url?
Here is the context so that you know why I am asking this question. I start by showing the code I am using. This is how I am registering the security provider:
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'client' => array(
'pattern' => '^/(en|fr)/client',
'form' => array('login_path' => "/fr/login", 'check_path' => "/fr/client/login_check"),
'users' => function () use ($app) {
return new UserProvider($app['pdoqueries']);
},
'logout' => array('logout_path' => '/logout', 'invalidate_session' => true),
),
)
));
Notice here that I am securing English and French urls (/en/client and /fr/client). I did not find a way to make login_path point to the right login url with the right locale, so I am hardcoding it to the French URL.
Now here is the login route:
$app->get('/{_locale}/login', function(Request $request) use ($app, $arrConfig) {
$referer = $request->headers->get('referer');
error_log(__FILE__ . ": " . __LINE__ . ": " . __FUNCTION__ ." : " . var_export($referer, true));
return $app['twig']->render('auth/form.twig', array(
'error' => $app['security.last_error']($request),
'last_username' => $app['session']->get('_security.last_username'),
'title' => 'Login',
'assetsUrl' => $arrConfig['assets_url']
));
})
->bind('login');
You can see that I already tried to get the referer from the request headers. It does not work unfortunately. I need a way to get the url that the user tried to access to get the locale from it and show the login form text in that locale. This information must be stored somewhere because after successful login the user is redirected to that url.
Thanks