Only generate one nonce per process

This commit is contained in:
Andy Miller
2015-11-23 19:07:46 -07:00
parent b8f00243e6
commit 965c8cfbe9

View File

@@ -15,6 +15,8 @@ abstract class Utils
{
use GravTrait;
protected static $nonce;
/**
* @param string $haystack
* @param string $needle
@@ -491,9 +493,15 @@ abstract class Utils
*/
public static function getNonce($action, $plusOneTick = false)
{
// Don't regenerate this again if not needed
if (isset(static::$nonce)) {
return static::$nonce;
}
$nonce = self::hash(self::generateNonceString($action, $plusOneTick));
$nonce = str_replace('/', 'SLASH', $nonce);
return $nonce;
static::$nonce = str_replace('/', 'SLASH', $nonce);
return static::$nonce;
}
/**