mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 05:11:27 +00:00 
			
		
		
		
	add qrcode and secret for 2-factor auth
This commit is contained in:
		
							parent
							
								
									4d7f228a4c
								
							
						
					
					
						commit
						7f9f118fba
					
				|  | @ -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(); | ||||
| 	}); | ||||
| }); | ||||
| <?php | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	function show() { /* {{{ */ | ||||
| 		$dms = $this->params['dms']; | ||||
| 		$user = $this->params['user']; | ||||
|  | @ -63,6 +75,20 @@ class SeedDMS_View_MyAccount extends SeedDMS_Bootstrap_Style { | |||
| 			echo "<div class=\"span12\">\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 "<table class=\"table-condensed\">\n"; | ||||
| 		print "<tr>\n"; | ||||
| 		print "<td>".getMLText("name")." : </td>\n"; | ||||
|  | @ -111,8 +137,22 @@ class SeedDMS_View_MyAccount extends SeedDMS_Bootstrap_Style { | |||
| <?php | ||||
| 			print "</td>\n"; | ||||
| 			print "</tr>\n"; | ||||
| 			print "<tr>\n"; | ||||
| 			print "<td>\n"; | ||||
| 			echo getMLText('2_factor_auth'); | ||||
| 			print "</td>\n"; | ||||
| 			print "<td>\n"; | ||||
| 			echo '<button class="btn btn-default" 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 "</div>"; | ||||
| 			print "</td>\n"; | ||||
| 			print "</tr>\n"; | ||||
| 		} | ||||
| 		print "</table>\n"; | ||||
| 
 | ||||
| 		print "</div>\n"; | ||||
| 		print "</div>\n"; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann