src/Http/Controllers/Adminarea/AccountTwoFactorController.php
public function enableTotp(Request $request, Google2FA $totpProvider)
    {
        $currentUser = $request->user($this->getGuard());
        $twoFactor = $currentUser->getTwoFactor();

        if (! $secret = array_get($twoFactor, 'totp.secret')) {
            $twoFactor['totp'] = [
                'enabled' => false,
                'secret' => $secret = $totpProvider->generateSecretKey(),
            ];

            $currentUser->fill(['two_factor' => $twoFactor])->forceSave();
        }

        $qrCode = $totpProvider->getQRCodeInline(config('app.name'), $currentUser->email, $secret);

        return view('cortex/auth::adminarea.pages.account-twofactor-totp', compact('secret', 'qrCode', 'twoFactor'));
    }
public function enableTotp(Request $request, Google2FA $totpProvider)
    {
        $currentUser = $request->user($this->getGuard());
        $twoFactor = $currentUser->getTwoFactor();

        if (! $secret = array_get($twoFactor, 'totp.secret')) {
            $twoFactor['totp'] = [
                'enabled' => false,
                'secret' => $secret = $totpProvider->generateSecretKey(),
            ];

            $currentUser->fill(['two_factor' => $twoFactor])->forceSave();
        }

        $qrCode = $totpProvider->getQRCodeInline(config('app.name'), $currentUser->email, $secret);

        return view('cortex/auth::adminarea.pages.account-twofactor-totp', compact('secret', 'qrCode', 'twoFactor'));
    }
public function enableTotp ( Request $ request , Google2FA $ totpProvider ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; if ( ! $ secret = array_get ( $ twoFactor , 'totp.secret' ) ) { $ twoFactor [ 'totp' ] = [ 'enabled' => false , 'secret' => $ secret = $ totpProvider -> generateSecretKey ( ) , ] ; $ currentUser -> fill ( [ 'two_factor' => $ twoFactor ] ) -> forceSave ( ) ; } $ qrCode = $ totpProvider -> getQRCodeInline ( config ( 'app.name' ) , $ currentUser -> email , $ secret ) ; return view ( 'cortex/auth::adminarea.pages.account-twofactor-totp' , compact ( 'secret' , 'qrCode' , 'twoFactor' ) ) ; }
Enable TwoFactor TOTP authentication.

@param \Illuminate\Http\Request      $request
@param \PragmaRX\Google2FA\Google2FA $totpProvider

@return \Illuminate\View\View
Enable TwoFactor TOTP authentication .