diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-10-09 15:04:37 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-10-09 15:04:37 +0400 |
commit | 3f8c6975783fc115765ef241db8d9ba48a8679ac (patch) | |
tree | 60a85b08ce3896846db590ad1255c019657ff28f /core/Tracker/Request.php | |
parent | 39887206fda4d237b260a370363139feda4d0d89 (diff) |
Instead of throwing exceptions, log a message in tracker.
Diffstat (limited to 'core/Tracker/Request.php')
-rw-r--r-- | core/Tracker/Request.php | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 3f9bc56d80..a31001b66a 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -338,6 +338,7 @@ class Request } if (!$this->isTimestampValid($cdt, $this->timestamp)) { Common::printDebug(sprintf("Datetime %s is not valid", date("Y-m-d H:i:m", $cdt))); + // TODO: should throw here return false; } @@ -346,19 +347,14 @@ class Request $isTimestampRecent = $timeFromNow < self::CUSTOM_TIMESTAMP_DOES_NOT_REQUIRE_TOKENAUTH_WHEN_NEWER_THAN; if (!$isTimestampRecent) { Common::printDebug(sprintf("Custom timestamp is %s seconds old, requires &token_auth...", $timeFromNow)); - $this->checkUserIsAuthenticated(); + if(!$this->isAuthenticated()) { + Common::printDebug("WARN: Tracker API 'cdt' was used with invalid token_auth"); + return false; + } } return $cdt; } - private function checkUserIsAuthenticated() - { - if (!$this->isAuthenticated()) { - throw new Exception("You must specify a valid &token_auth= parameter in order to use the &cip= parameter and/or the &cdt= parameter (when setting cdt to a datatime older than a few hours)."); - } - } - - /** * Returns true if the timestamp is valid ie. timestamp is sometime in the last 10 years and is not in the future. * @@ -644,11 +640,15 @@ class Request private function getIpString() { $cip = $this->getParam('cip'); - if (empty($cip)) { + + if(empty($cip)) { return IP::getIpFromHeader(); } - $this->checkUserIsAuthenticated(); + if(!$this->isAuthenticated()) { + Common::printDebug("WARN: Tracker API 'cdt' was used with invalid token_auth"); + return IP::getIpFromHeader(); + } return $cip; } } |