mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-08-24 15:56:34 +00:00
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
This commit is contained in:
+1
-1
@@ -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());
|
||||
?>
|
||||
<li>First create a secret and associate it with a user</li>
|
||||
<?php
|
||||
|
||||
@@ -8,7 +8,7 @@ abstract class BaseHTTPQRCodeProvider implements IQRCodeProvider
|
||||
{
|
||||
protected bool $verifyssl = true;
|
||||
|
||||
protected function getContent(string $url): string|bool
|
||||
protected function getContent(string $url): string
|
||||
{
|
||||
$curlhandle = curl_init();
|
||||
|
||||
@@ -22,6 +22,9 @@ abstract class BaseHTTPQRCodeProvider implements IQRCodeProvider
|
||||
CURLOPT_USERAGENT => 'TwoFactorAuth',
|
||||
));
|
||||
$data = curl_exec($curlhandle);
|
||||
if ($data === false) {
|
||||
throw new QRException(curl_error($curlhandle));
|
||||
}
|
||||
|
||||
curl_close($curlhandle);
|
||||
return $data;
|
||||
|
||||
Reference in New Issue
Block a user