Guest User

Untitled

a guest
Feb 11th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. Logged in as: anon.
  2. Authenticated: Yes
  3. Token class: AnonymousToken
  4. Firewall name: main
  5.  
  6. security:
  7. providers:
  8. database_users:
  9. entity: { class: AppEntityUser, property: email }
  10. encoders:
  11. AppEntityUser: bcrypt
  12. firewalls:
  13. dev:
  14. pattern: ^/(_(profiler|wdt)|css|images|js)/
  15. security: false
  16. main:
  17. pattern: ^/
  18. anonymous: true
  19. form_login:
  20. login_path: login
  21. check_path: login
  22. logout:
  23. path: logout
  24. target: home
  25. access_control:
  26. - { path: '^/admin', roles: ROLE_ADMIN }
  27.  
  28. framework:
  29. secret: '%env(APP_SECRET)%'
  30. session:
  31. handler_id: ~
  32. php_errors:
  33. log: true
  34.  
  35. <?php
  36.  
  37. namespace AppController;
  38.  
  39. use SymfonyBundleFrameworkBundleControllerController;
  40. use SymfonyComponentHttpFoundationRequest;
  41. use SymfonyComponentRoutingAnnotationRoute;
  42. use SymfonyComponentSecurityHttpAuthenticationAuthenticationUtils;
  43.  
  44. class SecurityController extends Controller
  45. {
  46. /**
  47. * @Route("/login", name="login")
  48. */
  49. public function loginAction(Request $request, AuthenticationUtils $authenticationUtils)
  50. {
  51. $error = $authenticationUtils->getLastAuthenticationError();
  52.  
  53. $lastUsername = $authenticationUtils->getLastUsername();
  54.  
  55. return $this->render('security/login.html.twig', array(
  56. 'last_username' => $lastUsername,
  57. 'error' => $error,
  58. ));
  59. }
  60.  
  61. /**
  62. * @Route("/logout", name="logout")
  63. */
  64. public function logoutAction()
  65. {
  66. throw $this->createAccessDeniedException();
  67. }
  68. }
  69.  
  70. {% if error %}
  71. <div>{{ error.messageKey|trans(error.messageData, 'security') }}</div>
  72. {% endif %}
  73.  
  74. <form action="{{ path('login') }}" method="post">
  75. <label for="username">Username:</label>
  76. <input type="text" id="username" name="_username" value="{{ last_username }}" />
  77.  
  78. <label for="password">Password:</label>
  79. <input type="password" id="password" name="_password" />
  80.  
  81. <button type="submit">login</button>
  82. </form>
Add Comment
Please, Sign In to add comment