thecodework/two-factor-authentication

Suggestion: submit issuer and user email with the barcode

ebonit opened this issue · 0 comments

I use the library in laravel and found that in the authenticator app I was missing my email address. I made an overwrite for the TwoFactorAuthenticationController as follows:

    public function setupTwoFactorAuthentication(Request $request)
    {
        $user = $this->getUser();
        $totp = TOTP::create(
            $this->base32EncodedString(),
            config('2fa-config.period'),
            config('2fa-config.digest_algorithm'),
            config('2fa-config.number_of_digits')
        );

//here is my change
        $totp->setLabel($user->email);
        $totp->setIssuer(config('2fa-config.account_name'));
//end of change

        $this->updateUserWithProvisionedUri($totp->getProvisioningUri());
        $barcode = $totp->getQrCodeUri();
        if ($request->ajax()) {
            return $barcode;
        }

        return view('2fa::setup', compact('barcode', 'user'));
    }

That way it is easier to see for which email address it is used for