Skip to content

Commit

Permalink
remove 'request->getRequestUri()' from action_url param, possible sol…
Browse files Browse the repository at this point in the history
…ution for #485
  • Loading branch information
SergeyMosin committed Mar 9, 2024
1 parent 4e1aaaa commit 215fe6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public function cncf($embed = false)

// take action automatically if "Skip email verification step" is set
$take_action = $a === '2';
$appt_action_url = '';
$appt_action_url_hash = '';
// issue https://github.com/SergeyMosin/Appointments/issues/293
if (!$take_action) {
// we only take action if we have $dh param and $dh matches $pd adler32 hash
Expand All @@ -317,7 +317,7 @@ public function cncf($embed = false)
return new NotFoundResponse();
}
} else {
$appt_action_url = $this->request->getRequestUri() . "&h=" . hash('adler32', $pd, false);
$appt_action_url_hash = hash('adler32', $pd, false);
}
}

Expand Down Expand Up @@ -419,7 +419,7 @@ public function cncf($embed = false)
$page_text = $this->l->t('Please confirm your appointment scheduled for %s.', [$date_time]);
// TRANSLATORS This is a button label
$tr_params['appt_action_url_text'] = $this->l->t("Confirm");
$tr_params['appt_action_url'] = $appt_action_url;
$tr_params['appt_action_url_hash'] = $appt_action_url_hash;
}
}
}
Expand Down Expand Up @@ -512,7 +512,7 @@ public function cncf($embed = false)
$page_text = $this->l->t('Would you like to cancel appointment scheduled for %s ?', [$date_time]);
// TRANSLATORS This is a button label
$tr_params['appt_action_url_text'] = $this->l->t("Yes, Cancel");
$tr_params['appt_action_url'] = $appt_action_url;
$tr_params['appt_action_url_hash'] = $appt_action_url_hash;
}
}
} elseif ($a === '3') {
Expand Down Expand Up @@ -573,7 +573,7 @@ public function cncf($embed = false)
$page_text = $this->l->t("Would you like to change your %s to %s?", [$lbl, $new_type]);
// TRANSLATORS This is a button label
$tr_params['appt_action_url_text'] = $this->l->t("Yes, Change");
$tr_params['appt_action_url'] = $appt_action_url;
$tr_params['appt_action_url_hash'] = $appt_action_url_hash;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cncf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
btn.addEventListener("click", function (e) {
/** @type {HTMLElement} */
let t = e.currentTarget
const attrName = 'data-appt-action-url'
const attrName = 'data-appt-action-url-hash'
if (t !== null && t.hasAttribute(attrName)) {
const uri = t.getAttribute(attrName)
const uri = window.location.pathname+window.location.search+'&h='+t.getAttribute(attrName)

//Avoid double clicks
t.removeAttribute(attrName)
Expand Down
4 changes: 2 additions & 2 deletions templates/public/thanks.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<div class="srgdev-appt-info-cont">
<h1><?php p($_['appt_c_head']) ?></h1>
<p><?php p($_['appt_c_msg']) ?></p>
<?php if (isset($_['appt_action_url'])) { ?>
<?php if (isset($_['appt_action_url_hash'])) { ?>
<button id="srgdev-appt-cncf_action_btn"
data-appt-action-url="<?php echo $_['appt_action_url'] ?>"
data-appt-action-url-hash="<?php echo $_['appt_action_url_hash'] ?>"
class="primary srgdev-ncfp-form-btn"
type="button"><span><?php p($_['appt_action_url_text']) ?></span><span id="srgdev-ncfp_fbtn-spinner"></span></button>
<?php } else { ?>
Expand Down

0 comments on commit 215fe6f

Please sign in to comment.