Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- encoders:
- SymfonyComponentSecurityCoreUserUser:
- algorithm: sha1
- iterations: 1
- encode_as_base64: false
- providers:
- in_memory:
- memory:
- users:
- # Passwords are encrypted using sha1() - https://www.tools4noobs.com/online_php_functions/sha1/
- admin: { password: 123456, roles: ['ROLE_ADMIN' ] }
- user1: { password: 654321, roles: ['ROLE_USER' ] }
- firewalls:
- dev:
- pattern: ^/(_(profiler|wdt|error)|css|images|js)/
- security: false
- main:
- pattern: ^/user/
- anonymous: ~
- logout:
- path: /user/logout
- target: /user/login
- form_login:
- login_path: /user/login
- check_path: /user/login-check
- default_target_path: /user/
- access_control:
- - { path: ^/_(?:wdt|profiler)/, role: IS_AUTHENTICATED_ANONYMOUSLY }
- - { path: ^/user/login, role: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
- - { path: ^/user/, role: ROLE_USER, requires_channel: https }
- role_hierarchy:
- ROLE_ADMIN: [ROLE_USER]
- /**
- * Class SecurityController
- * @package AppBundleController
- */
- class SecurityController extends Controller
- {
- /**
- * @Route("/user/login", name="user_login")
- * @Template()
- * @Method({"GET"})
- *
- * @param Request $request
- * @return Response
- */
- public function loginAction(Request $request)
- {
- /** @var Session $session */
- $session = $request->getSession();
- $authenticationUtils = $this->get('security.authentication_utils');
- // last username entered by the user
- $lastUsername = $authenticationUtils->getLastUsername();
- if ($session->getFlashBag()->has('error')){
- $error = $session->getFlashBag()->get('error');
- } else {
- // get the login error if there is one
- $error = $authenticationUtils->getLastAuthenticationError();
- }
- return $this->render('user/security/login.html.twig', [
- 'last_username' => $lastUsername,
- 'error' => $error
- ]);
- }
- /**
- * @Route("/user/login-check", name="user_login_check")
- * @Method({"POST"})
- */
- public function loginCheckAction()
- {
- // this controller will not be executed,
- // as the route is handled by the Security system
- }
- /**
- * Logout user
- *
- * @Route("/user/logout", name="user_logout")
- * @Method({"GET"})
- */
- public function logoutAction()
- {
- // this controller will not be executed,
- // as the route is handled by the Security system
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement