From 93fd4692f6eb753cae16358131c8049d84cfbb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 22 Jan 2015 08:30:07 +0100 Subject: symfony is there --- .../DemoBundle/Controller/SecuredController.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/Acme/DemoBundle/Controller/SecuredController.php (limited to 'src/Acme/DemoBundle/Controller/SecuredController.php') diff --git a/src/Acme/DemoBundle/Controller/SecuredController.php b/src/Acme/DemoBundle/Controller/SecuredController.php new file mode 100644 index 00000000..d1499e39 --- /dev/null +++ b/src/Acme/DemoBundle/Controller/SecuredController.php @@ -0,0 +1,70 @@ +attributes->has(SecurityContext::AUTHENTICATION_ERROR)) { + $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR); + } else { + $error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR); + } + + return array( + 'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME), + 'error' => $error, + ); + } + + /** + * @Route("/login_check", name="_demo_security_check") + */ + public function securityCheckAction() + { + // The security layer will intercept this request + } + + /** + * @Route("/logout", name="_demo_logout") + */ + public function logoutAction() + { + // The security layer will intercept this request + } + + /** + * @Route("/hello", defaults={"name"="World"}), + * @Route("/hello/{name}", name="_demo_secured_hello") + * @Template() + */ + public function helloAction($name) + { + return array('name' => $name); + } + + /** + * @Route("/hello/admin/{name}", name="_demo_secured_hello_admin") + * @Security("is_granted('ROLE_ADMIN')") + * @Template() + */ + public function helloadminAction($name) + { + return array('name' => $name); + } +} -- cgit v1.2.3