mirror of
https://git.code.sf.net/p/seeddms/code
synced 2026-01-15 05:48:15 +00:00
replace old code to show qrcode and secret of 2-factor auth
This commit is contained in:
parent
2339e539be
commit
085ffee971
|
|
@ -14,9 +14,12 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Include parent class
|
||||
* Include classes for 2-factor authentication
|
||||
*/
|
||||
//require_once("class.Bootstrap.php");
|
||||
require "vendor/autoload.php";
|
||||
|
||||
use RobThree\Auth\TwoFactorAuth;
|
||||
use RobThree\Auth\Providers\Qr\BaconQrCodeProvider;
|
||||
|
||||
/**
|
||||
* Class which outputs the html page for MyAccount view
|
||||
|
|
@ -125,34 +128,25 @@ $(document).ready( function() {
|
|||
print "</td>\n";
|
||||
print "</tr>\n";
|
||||
if($enable2factauth) {
|
||||
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('SeedDMS');
|
||||
$tfa = new TwoFactorAuth(new BaconQrCodeProvider());
|
||||
|
||||
print "<tr>\n";
|
||||
print "<td>\n";
|
||||
echo getMLText('2_factor_auth');
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
$secret = $user->getSecret();
|
||||
if(!$secret) {
|
||||
print "<td>\n";
|
||||
echo '<a class="btn btn-default" href="../out/out.Setup2Factor.php">'.getMLText('setup_2_fact_auth').'</a>';
|
||||
print "</td>\n";
|
||||
echo '<a class="btn btn-primary btn-sm" href="../out/out.Setup2Factor.php">'.getMLText('setup_2_fact_auth').'</a>';
|
||||
} else {
|
||||
print "<td>\n";
|
||||
echo '<button class="btn btn-default" id="toggleqrcode">'.getMLText('toggle_qrcode').'</button>';
|
||||
echo '<button class="btn btn-primary btn-sm" id="toggleqrcode">'.getMLText('toggle_qrcode').'</button>';
|
||||
echo '<div id="qrcode">';
|
||||
echo 'Code is: '.$code = $tfa->getCode($secret)."<br />";
|
||||
echo 'Secret: '.$secret."<br />";
|
||||
echo '<img src="' . $tfa->getQRCodeImageAsDataUri('My label', $secret) . '">';
|
||||
echo '<img src="' . $tfa->getQRCodeImageAsDataUri($user->getLogin(), $secret) . '">';
|
||||
echo "</div>";
|
||||
print "</td>\n";
|
||||
}
|
||||
print "</td>\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -165,4 +159,3 @@ $(document).ready( function() {
|
|||
$this->htmlEndPage();
|
||||
} /* }}} */
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user