Advertisement
Guest User

SecurityController

a guest
Jun 15th, 2017
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. <?php
  2. /**
  3. * SecurityController.php
  4. * User: draiz
  5. * Date: 14/06/2017
  6. * Time: 12:59
  7. */
  8.  
  9. namespace AdminBundle\Controller;
  10.  
  11.  
  12. use AdminBundle\Form\LoginForm;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  14. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  17.  
  18. class SecurityController extends Controller
  19. {
  20. /**
  21. * @Route("/admin/login", name="admin_security_login")
  22. */
  23. public function loginAction(Request $request, AuthenticationUtils $authUtils)
  24. {
  25.  
  26. // get the login error if there is one
  27. $error = $authUtils->getLastAuthenticationError();
  28.  
  29. // last username entered by the user
  30. $lastUsername = $authUtils->getLastUsername();
  31.  
  32. $form = $this->createForm(LoginForm::class, [
  33. '_username' => $lastUsername,
  34. ]);
  35.  
  36. return $this->render(
  37. '@Admin/security/login.html.twig',
  38. array(
  39. 'last_username' => $lastUsername,
  40. 'form' => $form->createView(),
  41. 'error' => $error,
  42. )
  43. );
  44. }
  45.  
  46. /**
  47. * @Route("/admin/logout", name="admin_security_logout")
  48. */
  49. public function logoutAction()
  50. {
  51. throw new \Exception('this should not be reached!');
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement