From 3ab38b2602719d091b47bc3868f54c7a4f513d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 6 Nov 2014 16:37:30 +0100 Subject: [PATCH] login form --- Controller/LoginController.php | 50 ++++++++++++++++++++++++ Resources/config/routing.yml | 6 +++ Resources/views/Login/login.html.twig | 19 +++++++++ Tests/Controller/LoginControllerTest.php | 16 ++++++++ 4 files changed, 91 insertions(+) create mode 100644 Controller/LoginController.php create mode 100644 Resources/views/Login/login.html.twig create mode 100644 Tests/Controller/LoginControllerTest.php diff --git a/Controller/LoginController.php b/Controller/LoginController.php new file mode 100644 index 000000000..1f3637130 --- /dev/null +++ b/Controller/LoginController.php @@ -0,0 +1,50 @@ +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) + { + + } + +} diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 4d42d1043..3ced09503 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -26,3 +26,9 @@ chill_main_admin_central: login: path: /login defaults: { _controller: ChillMainBundle:Login:login } + +login_check: + path: /login_check + +logout: + path: /logout diff --git a/Resources/views/Login/login.html.twig b/Resources/views/Login/login.html.twig new file mode 100644 index 000000000..fc978fb42 --- /dev/null +++ b/Resources/views/Login/login.html.twig @@ -0,0 +1,19 @@ +{% extends "::base.html.twig" %} + +{% block title %}ChillMainBundle:Login:login{% endblock %} + +{% block body %} +

Welcome to the Login:login page

+ +

{{ error }}

+ +
+ + + + + + +
+ +{% endblock %} diff --git a/Tests/Controller/LoginControllerTest.php b/Tests/Controller/LoginControllerTest.php new file mode 100644 index 000000000..c0b6e7faf --- /dev/null +++ b/Tests/Controller/LoginControllerTest.php @@ -0,0 +1,16 @@ +request('GET', '/login'); + } + +}