diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-03-09 21:24:04 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-03-09 21:24:04 -0500 |
commit | 6d814566fba8ac45b5cba6993e7b98223b259256 (patch) | |
tree | 199e1c456d721c4ca95b95092fbf619497ef073e /app/Controller | |
parent | cbb4d0061e698376d4fbd9a6df95ac14d0733aed (diff) |
Render QR code for TwoFactor authentication without Google Chart API
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/TwoFactorController.php | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/app/Controller/TwoFactorController.php b/app/Controller/TwoFactorController.php index d02c8950..73060c44 100644 --- a/app/Controller/TwoFactorController.php +++ b/app/Controller/TwoFactorController.php @@ -3,6 +3,7 @@ namespace Kanboard\Controller; use Kanboard\Core\Controller\AccessForbiddenException; +use PHPQRCode; /** * Two Factor Auth controller @@ -65,9 +66,8 @@ class TwoFactorController extends UserViewController } $this->response->html($this->helper->layout->user('twofactor/show', array( - 'user' => $user, - 'secret' => $this->sessionStorage->twoFactorSecret, - 'qrcode_url' => $provider->getQrCodeUrl($label), + 'user' => $user, + 'secret' => $this->sessionStorage->twoFactorSecret, 'key_url' => $provider->getKeyUrl($label), ))); } @@ -192,11 +192,28 @@ class TwoFactorController extends UserViewController 'twofactor_secret' => '', )); - return $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); + $this->response->redirect($this->helper->url->to('UserViewController', 'show', array('user_id' => $user['id']))); + } else { + $this->response->html($this->helper->layout->user('twofactor/disable', array( + 'user' => $user, + ))); } + } - return $this->response->html($this->helper->layout->user('twofactor/disable', array( - 'user' => $user, - ))); + /** + * Render QR Code image + */ + public function qrcode() + { + if (isset($this->sessionStorage->twoFactorSecret)) { + $user = $this->getUser(); + $provider = $this->authenticationManager->getPostAuthenticationProvider(); + $provider->setSecret($this->sessionStorage->twoFactorSecret); + $url = $provider->getKeyUrl($user['email'] ?: $user['username']); + + if (! empty($url)) { + PHPQRCode\QRcode::png($url, false, 'L', 6, 0); + } + } } } |