Beispiel #1
0
 /**
  * @param null $data
  * @param array $options
  * @return \Symfony\Component\Form\Form
  */
 public function getLoginForm($data = null, array $options = [])
 {
     $options['last_username'] = $this->authenticationUtils->getLastUsername();
     if (!array_key_exists('action', $options)) {
         $options['action'] = $this->router->generate('security_login_check');
     }
     return $this->formFactory->create(LoginType::class, $data, $options);
 }
Beispiel #2
0
 /**
  * @param AuthenticationUtils $utils
  * @param LoginFormType       $type
  *
  * @return array
  */
 public function loginAction(AuthenticationUtils $utils, LoginFormType $type)
 {
     /** If the user is already logged in, forward them to the homepage **/
     if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY')) {
         return new RedirectResponse($this->urlGenerator->generate('home'));
     }
     /** Create the form **/
     $loginForm = $this->formFactory->getSymfonyFormFactory()->createBuilder($type, null, ['action' => $this->urlGenerator->generate('login_check')])->getForm()->createView();
     return ['login_form' => $loginForm, 'error' => $utils->getLastAuthenticationError(), 'last_username' => $utils->getLastUsername()];
 }
 function it_renders_login_form(Request $request, ParameterBag $requestAttributes, AuthenticationUtils $authenticationUtils, FormFactoryInterface $formFactory, Form $form, FormView $formView, EngineInterface $templatingEngine, Response $response)
 {
     $authenticationUtils->getLastAuthenticationError()->willReturn('Bad credentials.');
     $authenticationUtils->getLastUsername()->willReturn('john.doe');
     $request->attributes = $requestAttributes;
     $requestAttributes->get('_sylius')->willReturn(['template' => 'CustomTemplateName', 'form' => 'custom_form_type']);
     $formFactory->createNamed('', 'custom_form_type')->willReturn($form);
     $form->createView()->willReturn($formView);
     $templatingEngine->renderResponse('CustomTemplateName', ['form' => $formView, 'last_username' => 'john.doe', 'last_error' => 'Bad credentials.'])->willReturn($response);
     $this->loginAction($request)->shouldReturn($response);
 }
 function it_renders_login_form(Request $request, ParameterBag $requestAttributes, AuthenticationUtils $authenticationUtils, FormFactoryInterface $formFactory, Form $form, FormView $formView, EngineInterface $templatingEngine, Response $response)
 {
     $authenticationUtils->getLastAuthenticationError()->willReturn('Bad credentials.');
     $authenticationUtils->getLastUsername()->willReturn('john.doe');
     $request->attributes = $requestAttributes;
     $requestAttributes->get('_sylius[template]', 'SyliusUiBundle:Security:login.html.twig', true)->willReturn('CustomTemplateName');
     $requestAttributes->get('_sylius[form]', 'sylius_security_login', true)->willReturn('custom_form_type');
     $formFactory->createNamed('', 'custom_form_type')->willReturn($form);
     $form->createView()->willReturn($formView);
     $templatingEngine->renderResponse('CustomTemplateName', array('form' => $formView, 'last_username' => 'john.doe', 'last_error' => 'Bad credentials.'))->willReturn($response);
     $this->loginAction($request)->shouldReturn($response);
 }
Beispiel #5
0
 public function loginAction()
 {
     $form = $this->formFactory->createNamed('', 'Shop\\Presentation\\Form\\LoginType', ['_username' => $this->utils->getLastUsername()], ['action' => $this->router->generate('login_check')]);
     $error = $this->utils->getLastAuthenticationError();
     return new Response($this->engine->render(':security:login.html.twig', ['form' => $form->createView(), 'error' => $error]));
 }
 public function loginAction()
 {
     return new Response($this->templateEngine->render($this->configResolver->getParameter('security.login_template'), array('last_username' => $this->authenticationUtils->getLastUsername(), 'error' => $this->authenticationUtils->getLastAuthenticationError(), 'layout' => $this->configResolver->getParameter('security.base_layout'))));
 }
 /**
  * @return string
  */
 public function getLastUsername()
 {
     return (string) $this->authenticationUtils->getLastUsername();
 }
 public function loginAction()
 {
     return $this->templating->renderResponse($this->loginActionTemplate, array('error' => $this->authenticationUtils->getLastAuthenticationError(), 'last_username' => $this->authenticationUtils->getLastUsername()));
 }
 /**
  * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating
  * @param \Symfony\Component\Security\Http\Authentication\AuthenticationUtils $authenticationUtils
  * @param \Symfony\Component\HttpFoundation\Response $response
  */
 function it_render_login_template_in_login_action($templating, $authenticationUtils, $response)
 {
     $error = new \Exception('message');
     $authenticationUtils->getLastAuthenticationError()->willReturn($error);
     $authenticationUtils->getLastUsername()->willReturn('user');
     $templating->renderResponse('FSiAdminSecurityBundle:Security:login.html.twig', array('error' => $error, 'last_username' => 'user'))->willReturn($response);
     $this->loginAction()->shouldReturn($response);
 }
Beispiel #10
-1
 /**
  * @param Request $request
  *
  * @return Response
  */
 public function loginAction(Request $request)
 {
     $lastError = $this->authenticationUtils->getLastAuthenticationError();
     $lastUsername = $this->authenticationUtils->getLastUsername();
     $template = $request->attributes->get('_sylius[template]', 'SyliusUiBundle:Security:login.html.twig', true);
     $formType = $request->attributes->get('_sylius[form]', 'sylius_security_login', true);
     $form = $this->formFactory->createNamed('', $formType);
     return $this->templatingEngine->renderResponse($template, ['form' => $form->createView(), 'last_username' => $lastUsername, 'last_error' => $lastError]);
 }
Beispiel #11
-1
 /**
  * @param Request $request
  *
  * @return Response
  */
 public function loginAction(Request $request)
 {
     $lastError = $this->authenticationUtils->getLastAuthenticationError();
     $lastUsername = $this->authenticationUtils->getLastUsername();
     $options = $request->attributes->get('_sylius');
     $template = isset($options['template']) ? $options['template'] : 'SyliusUiBundle:Security:login.html.twig';
     $formType = isset($options['form']) ? $options['form'] : SecurityLoginType::class;
     $form = $this->formFactory->createNamed('', $formType);
     return $this->templatingEngine->renderResponse($template, ['form' => $form->createView(), 'last_username' => $lastUsername, 'last_error' => $lastError]);
 }