Commit d1405f41 authored by Chenu Denis's avatar Chenu Denis
Browse files

[fix] Token date validation

parent a7ebdb35
...@@ -24,6 +24,7 @@ use Yii; ...@@ -24,6 +24,7 @@ use Yii;
use CHttpException; use CHttpException;
use Survey; use Survey;
use SurveyDynamic; use SurveyDynamic;
use Token;
class Utilities class Utilities
{ {
...@@ -369,14 +370,20 @@ class Utilities ...@@ -369,14 +370,20 @@ class Utilities
* @param string $token for control * @param string $token for control
* @return boolean * @return boolean
*/ */
public static function checkIsValidToken($surveyid, $token, $validtoken) public static function checkIsValidToken($surveyid, $token, $validtoken = null)
{ {
if (empty($validtoken)) {
return true;
}
if (empty($token)) { if (empty($token)) {
return false; return false;
} }
if (Survey::model()->findByPk($surveyid)->hasTokensTable) {
$oToken = Token::model($surveyid)->editable()->findByAttributes(array('token' => $token));
if(empty($oToken)) {
return false;
}
}
if (empty($validtoken)) {
return true;
}
if ($token == $validtoken) { if ($token == $validtoken) {
return true; return true;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment