public function activateGoogleAuthAction(Request $request)
    {
        $user = $this->getUser();
        
        $secret = $this->container->get("scheb_two_factor.security.google_authenticator")->generateSecret();
        $user->setGoogleAuthenticatorSecret($secret);

        //Generate QR url
        $qrUrl = $this->container->get("scheb_two_factor.security.google_authenticator")->getUrl($user);

        $form = $this->createForm(GoogleAuthType::class, $user);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->get('fos_user.user_manager')->updateUser($user, true);

            $this->addFlash('success', 'Your profile was updated successfully!');

            return $this->redirectToRoute('opifer_cms_user_profile');
        }

        return $this->render('OpiferCmsBundle:Backend/User:google_auth.html.twig', [
            'form' => $form->createView(),
            'secret' => $secret,
            'user' => $user,
            'qrUrl' => $qrUrl,
        ]);
    }
public function activateGoogleAuthAction(Request $request)
    {
        $user = $this->getUser();
        
        $secret = $this->container->get("scheb_two_factor.security.google_authenticator")->generateSecret();
        $user->setGoogleAuthenticatorSecret($secret);

        //Generate QR url
        $qrUrl = $this->container->get("scheb_two_factor.security.google_authenticator")->getUrl($user);

        $form = $this->createForm(GoogleAuthType::class, $user);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $this->get('fos_user.user_manager')->updateUser($user, true);

            $this->addFlash('success', 'Your profile was updated successfully!');

            return $this->redirectToRoute('opifer_cms_user_profile');
        }

        return $this->render('OpiferCmsBundle:Backend/User:google_auth.html.twig', [
            'form' => $form->createView(),
            'secret' => $secret,
            'user' => $user,
            'qrUrl' => $qrUrl,
        ]);
    }
public function activateGoogleAuthAction ( Request $ request ) { $ user = $ this -> getUser ( ) ; $ secret = $ this -> container -> get ( "scheb_two_factor.security.google_authenticator" ) -> generateSecret ( ) ; $ user -> setGoogleAuthenticatorSecret ( $ secret ) ; //Generate QR url $ qrUrl = $ this -> container -> get ( "scheb_two_factor.security.google_authenticator" ) -> getUrl ( $ user ) ; $ form = $ this -> createForm ( GoogleAuthType :: class , $ user ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ this -> get ( 'fos_user.user_manager' ) -> updateUser ( $ user , true ) ; $ this -> addFlash ( 'success' , 'Your profile was updated successfully!' ) ; return $ this -> redirectToRoute ( 'opifer_cms_user_profile' ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/User:google_auth.html.twig' , [ 'form' => $ form -> createView ( ) , 'secret' => $ secret , 'user' => $ user , 'qrUrl' => $ qrUrl , ] ) ; }
Activate Google Authenticator

@param Request $request

@return Response
Activate Google Authenticator