Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. encoders:
  2. SymfonyComponentSecurityCoreUserUser:
  3. algorithm: sha1
  4. iterations: 1
  5. encode_as_base64: false
  6. providers:
  7. in_memory:
  8. memory:
  9. users:
  10. # Passwords are encrypted using sha1() - https://www.tools4noobs.com/online_php_functions/sha1/
  11. admin: { password: 123456, roles: ['ROLE_ADMIN' ] }
  12. user1: { password: 654321, roles: ['ROLE_USER' ] }
  13.  
  14. firewalls:
  15. dev:
  16. pattern: ^/(_(profiler|wdt|error)|css|images|js)/
  17. security: false
  18.  
  19. main:
  20. pattern: ^/user/
  21. anonymous: ~
  22. logout:
  23. path: /user/logout
  24. target: /user/login
  25. form_login:
  26. login_path: /user/login
  27. check_path: /user/login-check
  28. default_target_path: /user/
  29.  
  30.  
  31. access_control:
  32. - { path: ^/_(?:wdt|profiler)/, role: IS_AUTHENTICATED_ANONYMOUSLY }
  33. - { path: ^/user/login, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
  34. - { path: ^/user/, role: ROLE_USER, requires_channel: https }
  35.  
  36. role_hierarchy:
  37. ROLE_ADMIN: [ROLE_USER]
  38.  
  39. /**
  40. * Class SecurityController
  41. * @package AppBundleController
  42. */
  43. class SecurityController extends Controller
  44. {
  45. /**
  46. * @Route("/user/login", name="user_login")
  47. * @Template()
  48. * @Method({"GET"})
  49. *
  50. * @param Request $request
  51. * @return Response
  52. */
  53. public function loginAction(Request $request)
  54. {
  55. /** @var Session $session */
  56. $session = $request->getSession();
  57.  
  58. $authenticationUtils = $this->get('security.authentication_utils');
  59. // last username entered by the user
  60. $lastUsername = $authenticationUtils->getLastUsername();
  61.  
  62. if ($session->getFlashBag()->has('error')){
  63. $error = $session->getFlashBag()->get('error');
  64. } else {
  65. // get the login error if there is one
  66. $error = $authenticationUtils->getLastAuthenticationError();
  67. }
  68.  
  69. return $this->render('user/security/login.html.twig', [
  70. 'last_username' => $lastUsername,
  71. 'error' => $error
  72. ]);
  73. }
  74.  
  75. /**
  76. * @Route("/user/login-check", name="user_login_check")
  77. * @Method({"POST"})
  78. */
  79. public function loginCheckAction()
  80. {
  81. // this controller will not be executed,
  82. // as the route is handled by the Security system
  83. }
  84.  
  85. /**
  86. * Logout user
  87. *
  88. * @Route("/user/logout", name="user_logout")
  89. * @Method({"GET"})
  90. */
  91. public function logoutAction()
  92. {
  93. // this controller will not be executed,
  94. // as the route is handled by the Security system
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement