From 7f9f118fba9d00d284aeb85d4de7e4459f0ebbc6 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 6 Jul 2016 22:26:23 +0200 Subject: [PATCH] add qrcode and secret for 2-factor auth --- views/bootstrap/class.MyAccount.php | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/views/bootstrap/class.MyAccount.php b/views/bootstrap/class.MyAccount.php index a999e3134..bbc51152d 100644 --- a/views/bootstrap/class.MyAccount.php +++ b/views/bootstrap/class.MyAccount.php @@ -31,6 +31,18 @@ require_once("class.Bootstrap.php"); */ class SeedDMS_View_MyAccount extends SeedDMS_Bootstrap_Style { + function js() { /* {{{ */ + header('Content-Type: application/javascript'); +?> +$(document).ready( function() { + $('#qrcode').hide(); + $( "#toggleqrcode" ).click(function() { + $('#qrcode').toggle(); + }); +}); +params['dms']; $user = $this->params['user']; @@ -63,6 +75,20 @@ class SeedDMS_View_MyAccount extends SeedDMS_Bootstrap_Style { echo "
\n"; } + require "vendor/robthree/twofactorauth/lib/Providers/Qr/IQRCodeProvider.php"; + require "vendor/robthree/twofactorauth/lib/Providers/Qr/BaseHTTPQRCodeProvider.php"; + require "vendor/robthree/twofactorauth/lib/Providers/Qr/GoogleQRCodeProvider.php"; + require "vendor/robthree/twofactorauth/lib/Providers/Rng/IRNGProvider.php"; + require "vendor/robthree/twofactorauth/lib/Providers/Rng/MCryptRNGProvider.php"; + require "vendor/robthree/twofactorauth/lib/TwoFactorAuthException.php"; + require "vendor/robthree/twofactorauth/lib/TwoFactorAuth.php"; + $tfa = new \RobThree\Auth\TwoFactorAuth('MyApp'); + + if($secret = $user->getSecret()) { + } else { + $secret = $tfa->createSecret(); + $user->setSecret($secret); + } print "\n"; print "\n"; print "\n"; @@ -111,8 +137,22 @@ class SeedDMS_View_MyAccount extends SeedDMS_Bootstrap_Style { \n"; print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; } print "
".getMLText("name")." :
\n"; + echo getMLText('2_factor_auth'); + print "\n"; + echo ''; + echo '
'; + echo 'Code is: '.$code = $tfa->getCode($secret)."
"; + echo 'Secret: '.$secret."
"; + echo ''; + echo "
"; + print "
\n"; + print "
\n"; print "\n";