Skip to content

Instantly share code, notes, and snippets.

@GabrielCW
Created December 17, 2015 09:31
Show Gist options
  • Save GabrielCW/55fabeb808adf91dd593 to your computer and use it in GitHub Desktop.
Save GabrielCW/55fabeb808adf91dd593 to your computer and use it in GitHub Desktop.
<?php
namespace Core\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Security;
/**
* Class SecurityController
*
* @author Gabriel Théron <gabriel@class-web.fr>
* @copyright Class Web 2015
* @package Core\UserBundle\Controller
*/
class SecurityController extends Controller
{
/**
* @return \Symfony\Component\HttpFoundation\Response
*/
public function loginAction()
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
//var_dump($error);
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'CoreUserBundle:Security:login.html.twig',
array(
// last username entered by the user
'last_username' => $lastUsername,
'error' => $error,
)
);
}
public function checkAction()
{
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}
public function logoutAction()
{
throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment