Merge pull request #18 from LinEvil/patch-1

Update TwoFactor.php
pull/33/head
AaronLiu 8 years ago committed by GitHub
commit 937dfc77fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,16 +18,17 @@ class TwoFactor extends Model{
$this->ga = new PHPGangsta_GoogleAuthenticator(); $this->ga = new PHPGangsta_GoogleAuthenticator();
} }
public function qrcodeRender(){ public function qrcodeRender(){
ob_end_clean(); ob_end_clean();
header("content-type: image/png"); $this->secretKey = $this->ga->createSecret();
$this->secretKey = $this->ga->createSecret(); session("two_factor_enable",$this->secretKey);
$qrCode = new QrCode(); $qrCode = new QrCode(urldecode($this->ga->getQRCodeGoogleUrl(Option::getValue("siteName"), $this->secretKey)));
session("two_factor_enable",$this->secretKey); $qrCode->setSize(165);
$qrCode->setText(urldecode($this->ga->getQRCodeGoogleUrl(Option::getValue("siteName"), $this->secretKey))) $qrCode->setMargin(0);
->setPadding(5) header('Content-Type: '.$qrCode->getContentType());
->render(); echo $qrCode->writeString();
} }
public function confirmCode($key,$code){ public function confirmCode($key,$code){
$this->secretKey = $key; $this->secretKey = $key;
@ -50,4 +51,4 @@ class TwoFactor extends Model{
} }
} }
?> ?>

Loading…
Cancel
Save