Created
December 29, 2011 21:03
-
-
Save henrikbjorn/1536189 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends '::base.html.twig' %} | |
{% block body %} | |
<form action="{{ path('my_security_login') }}" method="post"> | |
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" /> | |
{# Rest of the input fields and a submit button #} | |
</form> | |
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/config/security.yml | |
security: | |
firewalls: | |
default: | |
pattern: ^/ | |
form_login: | |
login_path: diveshare_session_new | |
check_path: diveshare_session_new | |
csrf_provider: form.csrf_provider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SecurityController | |
{ | |
public function loginAction() | |
{ | |
// Here goes all the normal stuff like getting the last username and error | |
// so we are playing $username and $error is already set. | |
$csrfToken = $this->container->get('form.csrf_provider')->generateCsrfToken('authentication'); | |
return $this->container->renderResponse('MyBundle:Security:login.html.twig', array( | |
'username' => $username, | |
'error' => $error, | |
'csrf_token' => $csrfToken, | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment