Skip to content

Commit

Permalink
Update tpw_session_refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
mangrose committed Jun 25, 2024
1 parent bf81c73 commit aca1cdd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions includes/class-tulo-paywall.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function get_back_url() {
public function get_return_url() {
$currentUrl = $this->get_current_url();
if (str_contains($currentUrl, "?")) {
$currentUrl .= "&tpw_session_refresh=1";
$currentUrl .= "&tpw_session_refresh=".time();
} else {
$currentUrl .= "?tpw_session_refresh=1";
$currentUrl .= "?tpw_session_refresh=".time();
}
return str_replace("http://", "https://", $currentUrl);
}
Expand Down
4 changes: 2 additions & 2 deletions includes/class-tulo-payway-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public function get_authentication_url() {
$permalinkStructure = get_option( 'permalink_structure' );
if ($permalinkStructure == "plain") {
$queryVars = $wp->query_vars;
$queryVars['tpw_session_refresh'] = '1';
$queryVars['tpw_session_refresh'] = time();
$currentUrl = add_query_arg( $queryVars, home_url( $wp->request ) );
} else {
$currentUrl .= "?tpw_session_refresh=1";
$currentUrl .= "?tpw_session_refresh=".time();
}
$currentOrg = get_option('tulo_organisation_id');
$authUrl = get_option('tulo_authentication_url');
Expand Down
7 changes: 6 additions & 1 deletion public/class-tulo-payway-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function check_session($wp)


if (strpos($_SERVER["REQUEST_URI"], "favicon") === false) {
if (get_query_var("tpw_session_refresh") == "1") {
if (get_query_var("tpw_session_refresh") != "") {
$this->common->write_log("!! forced session session refresh using query param");
$this->session->refresh();
$currentUrl = home_url( $wp->request );
Expand All @@ -114,6 +114,11 @@ public function check_session($wp)
unset($queryVars['tpw_session_refresh']);
$currentUrl = add_query_arg( $queryVars, home_url( $wp->request ) );
}
if (strpos($currentUrl, "?") === false) {
$currentUrl .= "?tpw=".time();
} else {
$currentUrl .= "&tpw=".time();
}
$this->common->write_log("!! session has been refreshed, redirecting to: ".$currentUrl);
header("Location: ".$currentUrl, true, 302);
die();
Expand Down

0 comments on commit aca1cdd

Please sign in to comment.