Skip to content

Commit

Permalink
Fixed problem where user is coming back from login originating at sta…
Browse files Browse the repository at this point in the history
…rtpage
  • Loading branch information
mangrose committed Jun 4, 2021
1 parent 8024a03 commit 72aacf4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 17 additions & 13 deletions public/class-tulo-payway-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ public function check_session($wp)
global $post;
if (is_admin())
return;

if (strpos($_SERVER["REQUEST_URI"], "favicon") === false) {
if (get_query_var("tpw_session_refresh") == "1") {
$this->common->write_log("!! forced session session refresh using query param");
$this->session->refresh();
$currentUrl = home_url( $wp->request );
$permalinkStructure = get_option( 'permalink_structure' );
if ($permalinkStructure == "plain") {
$queryVars = $wp->query_vars;
unset($queryVars['tpw_session_refresh']);
$currentUrl = add_query_arg( $queryVars, home_url( $wp->request ) );
}
$this->common->write_log("!! session has been refreshed, redirecting to: ".$currentUrl);
header("Location: ".$currentUrl, true, 302);
die();
}
}

if ( isset($post->ID) && strpos($_SERVER["REQUEST_URI"], "favicon") === false) {
$this->common->write_log("[check_session]");
Expand All @@ -94,19 +111,6 @@ public function check_session($wp)
$this->common->write_log("session not expired but page is restricted and user is not logged in, needs refresh");
$this->common->write_log($restrictions);
$this->session->refresh();
} else if (get_query_var("tpw_session_refresh") == "1") {
$this->common->write_log("!! forced session session refresh using query param");
$this->session->refresh();
$currentUrl = home_url( $wp->request );
$permalinkStructure = get_option( 'permalink_structure' );
if ($permalinkStructure == "plain") {
$queryVars = $wp->query_vars;
unset($queryVars['tpw_session_refresh']);
$currentUrl = add_query_arg( $queryVars, home_url( $wp->request ) );
}
$this->common->write_log("!! session has been refreshed, redirecting to: ".$currentUrl);
header("Location: ".$currentUrl, true, 302);
die();
}
}

Expand Down
4 changes: 2 additions & 2 deletions wp-tulo-payway.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* that starts the plugin.
*
* @link https://adeprimo.se
* @since 1.0.0
* @since 1.0.2
* @package Tulo_Payway_Server
*
* @wordpress-plugin
* Plugin Name: Tulo Payway Connector for Wordpress
* Description: This plugin integrates with the SSO2 single sign on solution in Tulo Payway.
* Version: 1.0.0
* Version: 1.0.2
* Author: Adeprimo AB
* Author URI: https://adeprimo.se
* Text Domain: tulo
Expand Down

0 comments on commit 72aacf4

Please sign in to comment.