php - Symfony2 Manual Redirect to Login, Preserving _security.main.target_path -
okay, know how via firewall. curious how symfony doing under hood , how can replicated manually.
i have tried things like:
return $this->redirect( '/login', 301 ); but when that, loses the
_security.main.target_path and thus, when user logs in, no longer redirected page on.
how redirect login in manner replicates firewall , preserves
_security.main.target_path ?
try following code
add setting in security.yml file
#app/config/security.yml security: firewalls: main: form_login: always_use_default_target_path: true target_path_parameter: redirect_url your login form must have following input tag
<input type="hidden" name="_target_path" value="account" /> like form
<form action="{{ path('login_check') }}" method="post"> <label for="username">username:</label> <input type="text" id="username" name="_username" value="{{ last_username }}" /> <label for="password">password:</label> <input type="password" id="password" name="_password" /> <input type="hidden" name="_target_path" value="account" /> <input type="submit" name="login" /> </form>
Comments
Post a Comment