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

33 lines
961 B
PHP
Raw Permalink Normal View History

2020-04-09 13:05:23 +02:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\{Base32,Totp};
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
*/
public function index(Request $request)
2020-04-09 13:05:23 +02: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');
}
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'));
}
2020-04-09 13:05:23 +02:00
}