mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-21 09:03:38 +02:00
(cp 9ac99be1d) fixes GHSA-9986-w7jf-33f6 and fixes GHSA-9986-w7jf-33f6
not include password.tpl from standard pages
This commit is contained in:
@@ -2005,4 +2005,40 @@ SELECT COUNT(*)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an user code for verification
|
||||
*
|
||||
* @since 16
|
||||
* @return array [$secret, $code]
|
||||
*/
|
||||
function generate_user_code()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
require_once(PHPWG_ROOT_PATH . 'include/totp.class.php');
|
||||
$secret = PwgTOTP::generateSecret();
|
||||
$code = PwgTOTP::generateCode($secret, min($conf['password_reset_code_duration'], 900)); // max 15 minutes
|
||||
|
||||
return array(
|
||||
'secret' => $secret,
|
||||
'code' => $code
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify user code
|
||||
*
|
||||
* @since 16
|
||||
* @param string $secret
|
||||
* @param string $code
|
||||
* @return bool
|
||||
*/
|
||||
function verify_user_code($secret, $code)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
require_once(PHPWG_ROOT_PATH . 'include/totp.class.php');
|
||||
return PwgTOTP::verifyCode($code, $secret, min($conf['password_reset_code_duration'], 900), 1);
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user