37 lines
1 KiB
PHP
37 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
/**
|
|
* Show the application dashboard.
|
|
*
|
|
* @return \Illuminate\Contracts\Support\Renderable
|
|
*/
|
|
public function index()
|
|
{
|
|
// $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');
|
|
}
|
|
|
|
/**
|
|
* Generate QR code
|
|
*
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
*/
|
|
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'));
|
|
}
|
|
}
|