Skip to content

Instantly share code, notes, and snippets.

@henrikbjorn
Created December 29, 2011 21:03
Show Gist options
  • Save henrikbjorn/1536189 to your computer and use it in GitHub Desktop.
Save henrikbjorn/1536189 to your computer and use it in GitHub Desktop.
{% 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 %}
# 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
<?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