aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Acme/DemoBundle/Controller/SecuredController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Acme/DemoBundle/Controller/SecuredController.php')
-rw-r--r--src/Acme/DemoBundle/Controller/SecuredController.php70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/Acme/DemoBundle/Controller/SecuredController.php b/src/Acme/DemoBundle/Controller/SecuredController.php
deleted file mode 100644
index d1499e39..00000000
--- a/src/Acme/DemoBundle/Controller/SecuredController.php
+++ /dev/null
@@ -1,70 +0,0 @@
1<?php
2
3namespace Acme\DemoBundle\Controller;
4
5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Security\Core\SecurityContext;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
11
12/**
13 * @Route("/demo/secured")
14 */
15class SecuredController extends Controller
16{
17 /**
18 * @Route("/login", name="_demo_login")
19 * @Template()
20 */
21 public function loginAction(Request $request)
22 {
23 if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
24 $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
25 } else {
26 $error = $request->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
27 }
28
29 return array(
30 'last_username' => $request->getSession()->get(SecurityContext::LAST_USERNAME),
31 'error' => $error,
32 );
33 }
34
35 /**
36 * @Route("/login_check", name="_demo_security_check")
37 */
38 public function securityCheckAction()
39 {
40 // The security layer will intercept this request
41 }
42
43 /**
44 * @Route("/logout", name="_demo_logout")
45 */
46 public function logoutAction()
47 {
48 // The security layer will intercept this request
49 }
50
51 /**
52 * @Route("/hello", defaults={"name"="World"}),
53 * @Route("/hello/{name}", name="_demo_secured_hello")
54 * @Template()
55 */
56 public function helloAction($name)
57 {
58 return array('name' => $name);
59 }
60
61 /**
62 * @Route("/hello/admin/{name}", name="_demo_secured_hello_admin")
63 * @Security("is_granted('ROLE_ADMIN')")
64 * @Template()
65 */
66 public function helloadminAction($name)
67 {
68 return array('name' => $name);
69 }
70}