public function getLogin(Request $request)
    {
        $user = $this->getUser();
        if ($user && $user->getEnabled() == 1) {
            $response = $this->redirectToRoute('dashboard');

            $token = $this->session()->get('authentication');
            $this->setAuthenticationCookie($request, $response, $token);

            return $response;
        }

        if ($this->getOption('general/enforce_ssl') && !$request->isSecure()) {
            return $this->redirect(preg_replace('/^http:/i', 'https:', $request->getUri()));
        }

        $userEntity = new Entity\Users();
        // Generate the form
        $form = $this->createFormBuilder(FormType\UserLoginType::class, $userEntity)
            ->getForm()
            ->handleRequest($request)
        ;
        /** @var Form $form */
        if ($form->isSubmitted() && $form->isValid()) {
            $action = $form->getClickedButton()->getName();
            if ($action === 'login') {
                $response = $this->handlePostLogin($request, $form);
            } elseif ($action === 'reset') {
                $response = $this->handlePostReset($request, $form);
            } else {
                // Let's not disclose any internal information.
                throw new HttpException(Response::HTTP_BAD_REQUEST, 'Invalid request');
            }
            if ($response instanceof Response) {
                return $response;
            }
        }
        $context = [
            'form'        => $form->createView(),
            'randomquote' => true,
        ];

        return $this->render('@bolt/login/login.twig', $context);
    }
public function getLogin(Request $request)
    {
        $user = $this->getUser();
        if ($user && $user->getEnabled() == 1) {
            $response = $this->redirectToRoute('dashboard');

            $token = $this->session()->get('authentication');
            $this->setAuthenticationCookie($request, $response, $token);

            return $response;
        }

        if ($this->getOption('general/enforce_ssl') && !$request->isSecure()) {
            return $this->redirect(preg_replace('/^http:/i', 'https:', $request->getUri()));
        }

        $userEntity = new Entity\Users();
        // Generate the form
        $form = $this->createFormBuilder(FormType\UserLoginType::class, $userEntity)
            ->getForm()
            ->handleRequest($request)
        ;
        /** @var Form $form */
        if ($form->isSubmitted() && $form->isValid()) {
            $action = $form->getClickedButton()->getName();
            if ($action === 'login') {
                $response = $this->handlePostLogin($request, $form);
            } elseif ($action === 'reset') {
                $response = $this->handlePostReset($request, $form);
            } else {
                // Let's not disclose any internal information.
                throw new HttpException(Response::HTTP_BAD_REQUEST, 'Invalid request');
            }
            if ($response instanceof Response) {
                return $response;
            }
        }
        $context = [
            'form'        => $form->createView(),
            'randomquote' => true,
        ];

        return $this->render('@bolt/login/login.twig', $context);
    }
public function getLogin ( Request $ request ) { $ user = $ this -> getUser ( ) ; if ( $ user && $ user -> getEnabled ( ) == 1 ) { $ response = $ this -> redirectToRoute ( 'dashboard' ) ; $ token = $ this -> session ( ) -> get ( 'authentication' ) ; $ this -> setAuthenticationCookie ( $ request , $ response , $ token ) ; return $ response ; } if ( $ this -> getOption ( 'general/enforce_ssl' ) && ! $ request -> isSecure ( ) ) { return $ this -> redirect ( preg_replace ( '/^http:/i' , 'https:' , $ request -> getUri ( ) ) ) ; } $ userEntity = new Entity \ Users ( ) ; // Generate the form $ form = $ this -> createFormBuilder ( FormType \ UserLoginType :: class , $ userEntity ) -> getForm ( ) -> handleRequest ( $ request ) ; /** @var Form $form */ if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ action = $ form -> getClickedButton ( ) -> getName ( ) ; if ( $ action === 'login' ) { $ response = $ this -> handlePostLogin ( $ request , $ form ) ; } elseif ( $ action === 'reset' ) { $ response = $ this -> handlePostReset ( $ request , $ form ) ; } else { // Let's not disclose any internal information. throw new HttpException ( Response :: HTTP_BAD_REQUEST , 'Invalid request' ) ; } if ( $ response instanceof Response ) { return $ response ; } } $ context = [ 'form' => $ form -> createView ( ) , 'randomquote' => true , ] ; return $ this -> render ( '@bolt/login/login.twig' , $ context ) ; }
Login page and "Forgotten password" page.

@param Request $request

@return TemplateResponse|RedirectResponse|Response
Login page and Forgotten password page .