2018-09-06 16:46:33 +02:00
|
|
|
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author kevinfrantz
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class SecurityController extends AbstractController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @Route("/login", name="login")
|
|
|
|
*/
|
|
|
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
|
|
|
{
|
|
|
|
$error = $authenticationUtils->getLastAuthenticationError();
|
|
|
|
if ($error) {
|
2018-09-06 17:22:08 +02:00
|
|
|
$this->addFlash('danger', $error->getMessage());
|
2018-09-06 20:20:29 +02:00
|
|
|
}else{
|
|
|
|
$this->addFlash('success', "User loged in.");
|
2018-09-06 16:46:33 +02:00
|
|
|
}
|
2018-09-06 20:20:29 +02:00
|
|
|
$this->addFlash('info', $authenticationUtils->getLastUsername());
|
2018-09-06 16:46:33 +02:00
|
|
|
return $this->render("user/login.html.twig",[
|
|
|
|
'last_username'=>$authenticationUtils->getLastUsername(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|