Commit 3325915b authored by Mahesh Patil's avatar Mahesh Patil
Browse files

[rtub] Fix hash equal issue.

parent 942ad596
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ function _rtub_save_event($eventName, $message) {

    }
    catch (exception $e) {
      \Drupal::logger('rtub')->warning(print_r('Something went wrong', TRUE));
      \Drupal::logger('rtub')->error('Message: ' .$e->getMessage());
    }
  }
}
@@ -101,7 +101,7 @@ function rtub_preprocess_node(&$variables) {
    $variables['#attached']['drupalSettings']['rtub']['nodeview']['eventData'] = $node->getTitle();
    $variables['#attached']['drupalSettings']['rtub']['nodeview']['eventType'] = "nodeview";

    $eStr = Crypt::hmacBase64(_get_cript_data($node->getTitle(), 'nodeview'), Settings::getHashSalt());
    $eStr = Crypt::hmacBase64(rtub_get_cript_data($node->getTitle(), 'nodeview'), Settings::getHashSalt());

    $variables['#attached']['drupalSettings']['rtub']['nodeview']['eventToken'] = $eStr;
  }
@@ -118,6 +118,6 @@ function rtub_preprocess_node(&$variables) {
 * @return string
 *   return string.
 */
function _get_cript_data($title, $type) {
function rtub_get_cript_data($title, $type) {
  return "User on {$title} | {$type}";
}
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ class PostNodeDataController extends ControllerBase {
    $newStr = "User on {$title} | {$type}";
    $eStr = Crypt::hmacBase64($newStr, Settings::getHashSalt());

    if ($event['eToken'] == $eStr) {
    if (hash_equals($eStr, $event['eToken'])) {
      // Valid post request.
      $connection = $this->connection;
      $connection->insert('rtub')