From 31f1eb839fe7e81cdf6f07e128279acf7c33c87b Mon Sep 17 00:00:00 2001 From: LinEvil Date: Sun, 18 Feb 2018 21:32:18 +0800 Subject: [PATCH] Update TwoFactor.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 安装的依赖endroid/qrcode已经弃用 请使用composer require endroid/qr-code --- application/index/model/TwoFactor.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/application/index/model/TwoFactor.php b/application/index/model/TwoFactor.php index 430b0116..0b01334a 100644 --- a/application/index/model/TwoFactor.php +++ b/application/index/model/TwoFactor.php @@ -18,16 +18,17 @@ class TwoFactor extends Model{ $this->ga = new PHPGangsta_GoogleAuthenticator(); } - public function qrcodeRender(){ - ob_end_clean(); - header("content-type: image/png"); - $this->secretKey = $this->ga->createSecret(); - $qrCode = new QrCode(); - session("two_factor_enable",$this->secretKey); - $qrCode->setText(urldecode($this->ga->getQRCodeGoogleUrl(Option::getValue("siteName"), $this->secretKey))) - ->setPadding(5) - ->render(); - } + public function qrcodeRender(){ + ob_end_clean(); + $this->secretKey = $this->ga->createSecret(); + session("two_factor_enable",$this->secretKey); + $qrCode = new QrCode(urldecode($this->ga->getQRCodeGoogleUrl(Option::getValue("siteName"), $this->secretKey))); + $qrCode->setSize(165); + $qrCode->setMargin(0); + header('Content-Type: '.$qrCode->getContentType()); + echo $qrCode->writeString(); + } + public function confirmCode($key,$code){ $this->secretKey = $key; @@ -50,4 +51,4 @@ class TwoFactor extends Model{ } } -?> \ No newline at end of file +?>