login form

This commit is contained in:
2014-11-06 16:37:30 +01:00
parent 0de9cb3a69
commit 3ab38b2602
4 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace Chill\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\SecurityContextInterface;
class LoginController extends Controller
{
/**
*
* @todo Improve this with http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements#added-a-security-error-helper
* @param Request $request
* @return Response
*/
public function loginAction(Request $request)
{
$session = $request->getSession();
if ($request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
$error = $request->attributes->get(
SecurityContextInterface::AUTHENTICATION_ERROR
);
} elseif (null !== $session && $session->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
$error = $session->get(SecurityContextInterface::AUTHENTICATION_ERROR);
$session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
} else {
$error = '';
}
$lastUsername = (null === $session) ?
'' : $session->get(SecurityContextInterface::LAST_USERNAME);
return $this->render('ChillMainBundle:Login:login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error
));
}
public function LoginCheckAction(Request $request)
{
}
}