ldc-web/app/Http/Controllers/HomeController.php

38 lines
1 KiB
PHP
Raw Normal View History

2020-04-09 13:05:23 +02:00
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
2020-04-09 13:05:23 +02:00
class HomeController extends Controller
{
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
2022-09-21 11:17:58 +00:00
public function index()
2020-04-09 13:05:23 +02:00
{
2022-09-21 11:17:58 +00:00
// $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
2020-04-09 13:05:23 +02:00
return view('home');
}
2022-09-21 11:17:58 +00:00
/**
* Generate QR code
*
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
public function qr()
{
2022-09-21 11:17:58 +00:00
$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'));
}
2020-04-09 13:05:23 +02:00
}