From 6f781411964daba860233f21aef26bc6c823f71b Mon Sep 17 00:00:00 2001 From: Nicolas CARPi Date: Tue, 7 May 2024 03:08:31 +0200 Subject: [PATCH] handle curl errors. fix #129 if curl fails for some reason to get a QR code from an external (http) provider, the app will throw a TwoFactorAuthException. also fix the demo page with new constructor signature --- demo/demo.php | 2 +- lib/Providers/Qr/BaseHTTPQRCodeProvider.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/demo/demo.php b/demo/demo.php index 9139381..14abcfb 100644 --- a/demo/demo.php +++ b/demo/demo.php @@ -12,7 +12,7 @@ }); // substitute your company or app name here - $tfa = new RobThree\Auth\TwoFactorAuth('RobThree TwoFactorAuth'); + $tfa = new RobThree\Auth\TwoFactorAuth(new RobThree\Auth\Providers\Qr\QRServerProvider()); ?>
  • First create a secret and associate it with a user
  • 'TwoFactorAuth', )); $data = curl_exec($curlhandle); + if ($data === false) { + throw new TwoFactorAuthException(curl_error($curlhandle)); + } curl_close($curlhandle); return $data;