enable qrcode generation for totp secrets

Uncommented and activated QR code generation in getQrCode(), allowing TOTP secrets to be encoded as base64 PNG images for easier setup in authenticator apps.
This commit is contained in:
Linty
2025-10-29 12:23:54 +01:00
parent 99bb370b98
commit d600b019a6

View File

@@ -2,6 +2,7 @@
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
require_once(PHPWG_ROOT_PATH . 'include/base32.class.php');
require_once(PHPWG_ROOT_PATH . 'include/phpqrcode.php');
class PwgTOTP
{
@@ -62,14 +63,13 @@ class PwgTOTP
*/
public static function getQrCode($secret)
{
// require_once(TF_REALPATH . 'include/phpqrcode.php');
// $otp_url = self::getOtpAuthUrl($secret);
$otp_url = self::getOtpAuthUrl($secret);
// ob_start();
// QRcode::png($otp_url);
// $qrcode_image = ob_get_clean();
// $base64_qrcode = base64_encode($qrcode_image);
// return 'data:image/png;base64,' . $base64_qrcode;
ob_start();
QRcode::png($otp_url);
$qrcode_image = ob_get_clean();
$base64_qrcode = base64_encode($qrcode_image);
return 'data:image/png;base64,' . $base64_qrcode;
}
/**