diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-01-11 02:48:50 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-01-11 02:54:13 +0400 |
commit | fb5454b703d00d50fb90fb7ddd0aa58656728093 (patch) | |
tree | fc5626edf1701b9c35baa1c5965a5dc5487067ba /core/Nonce.php | |
parent | 15853da8b03f0ab7a858a2335e9dbd62b7db4116 (diff) |
Fixes #4493, move DoNotTrack & AnonymizeIP logic to PrivacyManager plugin. Includes modification to EventDipatcher to allow generic callbacks in getListHooksRegistered method.
Diffstat (limited to 'core/Nonce.php')
-rw-r--r-- | core/Nonce.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/Nonce.php b/core/Nonce.php index 55567e8841..0fc84c3f6b 100644 --- a/core/Nonce.php +++ b/core/Nonce.php @@ -154,4 +154,25 @@ class Nonce return $origins; } + + /** + * Verifies and discards a nonce. + * + * @param string $nonceName The nonce's unique ID. See {@link getNonce()}. + * @param string|null $nonce The nonce from the client. If `null`, the value from the + * **nonce** query parameter is used. + * @throws Exception if the nonce is invalid. See {@link verifyNonce()}. + */ + static public function checkNonce($nonceName, $nonce = null) + { + if ($nonce === null) { + $nonce = Common::getRequestVar('nonce', null, 'string'); + } + + if (!self::verifyNonce($nonceName, $nonce)) { + throw new \Exception(Piwik::translate('General_ExceptionNonceMismatch')); + } + + self::discardNonce($nonceName); + } }
\ No newline at end of file |