mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-06 21:26:22 +01:00
* Don't allow per get request to disable 2fa * Fix google recaptcha issue * Fix rec key check * Make input auth code required + autofocus
42 lines
895 B
PHP
42 lines
895 B
PHP
<?php
|
|
defined('MYAAC') or die('Direct access not allowed!');
|
|
|
|
use MyAAC\TwoFactorAuth\TwoFactorAuth;
|
|
|
|
csrfProtect();
|
|
|
|
$title = 'Two Factor Authentication';
|
|
|
|
/**
|
|
* @var OTS_Account $account_logged
|
|
*/
|
|
$code = $_REQUEST['auth-code'] ?? '';
|
|
|
|
if (!$account_logged->isLoaded()) {
|
|
$current_session = getSession('account');
|
|
if($current_session) {
|
|
$account_logged = new OTS_Account();
|
|
$account_logged->load($current_session);
|
|
}
|
|
}
|
|
|
|
$twoFactorAuth = TwoFactorAuth::getInstance($account_logged);
|
|
$twig->addGlobal('account_logged', $account_logged);
|
|
|
|
/**
|
|
* Took from ZnoteAAC
|
|
* @author Znote
|
|
*/
|
|
function generateRandom2faSecret($length = 16): string
|
|
{
|
|
$characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
$charactersLength = strlen($characters);
|
|
$randomString = '';
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
}
|
|
|
|
return $randomString;
|
|
}
|