32 lines
961 B
PHP
32 lines
961 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use lfkeitel\phptotp\{Base32,Totp};
|
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Contracts\Support\Renderable
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
//$secret = Totp::GenerateSecret(16);
|
|
# Display new key to user so they can enter it in Google Authenticator or Authy
|
|
//echo strtoupper(Base32::encode($secret));exit;
|
|
// otpauth://totp/LDC%20WEB:mail@ldc.fr?secret=secret&issuer=LDC%20WEB
|
|
return view('home');
|
|
}
|
|
|
|
public function qr()
|
|
{
|
|
$user = Auth::user();
|
|
$qrcode = QrCode::size(200)->generate("otpauth://totp/LDC%20WEB:".$user->email."?secret=".$user->totp_secret."&issuer=LDC%20WEB");
|
|
return view("qrcode", compact('qrcode'));
|
|
}
|
|
}
|