forked from D3Public/oxtotp
use internal QR code generator instead of googleapi service
This commit is contained in:
parent
12294725bc
commit
2dde73ee61
@ -34,7 +34,8 @@
|
||||
"require": {
|
||||
"php": ">=5.6",
|
||||
"oxid-esales/oxideshop-metapackage-ce": "~6.0.3 || ~6.1.0",
|
||||
"spomky-labs/otphp": "^8.3 || ^9.0"
|
||||
"spomky-labs/otphp": "^8.3 || ^9.0",
|
||||
"bacon/bacon-qr-code": "^1.0 || ^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -15,6 +15,10 @@
|
||||
|
||||
namespace D3\Totp\Application\Model;
|
||||
|
||||
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||
use BaconQrCode\Writer;
|
||||
use D3\ModCfg\Application\Model\d3database;
|
||||
use D3\Totp\Application\Model\Exceptions\d3totp_wrongOtpException;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
@ -138,7 +142,7 @@ class d3totp extends BaseModel
|
||||
$this->totp = TOTP::create($seed ? $seed : $this->getSavedSecret());
|
||||
$this->totp->setLabel($this->getUser()->getFieldData('oxusername')
|
||||
? $this->getUser()->getFieldData('oxusername')
|
||||
: null
|
||||
: ''
|
||||
);
|
||||
}
|
||||
$this->totp->setIssuer(Registry::getConfig()->getActiveShop()->getFieldData('oxname'));
|
||||
@ -165,6 +169,21 @@ class d3totp extends BaseModel
|
||||
return $this->getTotp()->getQrCodeUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getQrCodeElement()
|
||||
{
|
||||
/** @var ImageRenderer $renderer */
|
||||
$renderer = oxNew(ImageRenderer::class,
|
||||
oxNew(RendererStyle::class, 200),
|
||||
oxNew(SvgImageBackEnd::class)
|
||||
);
|
||||
/** @var Writer $writer */
|
||||
$writer = oxNew(Writer::class, $renderer);
|
||||
return $writer->writeString($this->getTotp()->getProvisioningUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@
|
||||
[{oxmultilang ident="D3_TOTP_QRCODE"}]
|
||||
</td>
|
||||
<td class="edittext">
|
||||
<img src="[{$totp->getQrCodeUri()}]">
|
||||
[{$totp->getQrCodeElement()}]
|
||||
[{oxinputhelp ident="D3_TOTP_QRCODE_HELP"}]
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user