Skip to content

Commit

Permalink
Updated session status check and temporarily disabled updating datala…
Browse files Browse the repository at this point in the history
…yer/localstorage
  • Loading branch information
mangrose committed Jun 25, 2024
1 parent 50b2444 commit bf81c73
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
10 changes: 5 additions & 5 deletions admin/tulo-payway-server-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function tulo_server_render_landing($label, $name)
</tr>
<?php }

function tulo_server_render_bool_option_setting($label, $name, $helper = null)
function tulo_server_render_bool_option_setting($label, $name, $helper = null, $disabled = false)
{

$value = get_option($name);
Expand All @@ -108,7 +108,7 @@ function tulo_server_render_bool_option_setting($label, $name, $helper = null)
</label>
</th>
<td>
<input class="regular-checkbox " type="checkbox" name="<?php echo $name ?>" id="<?php echo $name ?>" <?php echo $value ? 'checked="checked"':''?> />
<input <?php echo $disabled==true ? "disabled": ""?> class="regular-checkbox " type="checkbox" name="<?php echo $name ?>" id="<?php echo $name ?>" <?php echo $value ? 'checked="checked"':''?> />
<?php if($helper != null){
echo $helper;
} ?>
Expand Down Expand Up @@ -284,9 +284,9 @@ function tulo_server_render_whitelist_ips() {
tulo_server_render_text_option_setting(__('Authentication URL', 'tulo'), 'tulo_authentication_url');
tulo_server_render_text_option_setting(__('Session refresh timeout', 'tulo'), 'tulo_session_refresh_timeout', __('seconds', 'tulo'));
tulo_server_render_text_option_setting(__('Organisation id', 'tulo'), 'tulo_organisation_id');
tulo_server_render_bool_option_setting(__('Expose account id', 'tulo'), 'tulo_expose_account_id', __('Help expose account id', 'tulo'));
tulo_server_render_bool_option_setting(__('Expose email', 'tulo'), 'tulo_expose_email', __('Help expose email', 'tulo'));
tulo_server_render_bool_option_setting(__('Expose customer number', 'tulo'), 'tulo_expose_customer_number', __('Help expose customer number', 'tulo'));
tulo_server_render_bool_option_setting(__('Expose account id', 'tulo'), 'tulo_expose_account_id', __('Help expose account id', 'tulo'), $disabled = true);
tulo_server_render_bool_option_setting(__('Expose email', 'tulo'), 'tulo_expose_email', __('Help expose email', 'tulo'), $disabled = true);
tulo_server_render_bool_option_setting(__('Expose customer number', 'tulo'), 'tulo_expose_customer_number', __('Help expose customer number', 'tulo'), $disabled = true);

$posttypes = Tulo_Payway_Server_Admin::get_post_types();

Expand Down
6 changes: 4 additions & 2 deletions includes/class-tulo-payway-sso2-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,11 @@ protected function refresh_session() {
}

$this->common->write_log("session status: <".$decoded->sts. "> at: ".$decoded->at);
if ($decoded->sts == "terminated") {
$this->common->write_log("session terminated in other window, logging out user");
if ($decoded->sts == "terminated" || $decoded->err == "session_not_found") {
$this->common->write_log("session terminated in other window or expired, logging out user locally also and establishing new session");
$this->logout_user(false);
$this->identify_session(); // Re-establish session after logout

} else if ($decoded->sts == "loggedin") {
$this->register_basic_session($decoded);
if ($lks == "anon" || $lks == "terminated") {
Expand Down
8 changes: 8 additions & 0 deletions public/class-tulo-payway-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ private function get_data_layer() {
$userEmail = "";
$userCustomerNumber = "";
$userProducts = '[]';

// set empty for now
return ' if (window.dataLayer!==undefined) { dataLayer.push({"tulo": {"user" : { "id": "'.$userId.'", "email": "'.$userEmail.'", "customer_number": "'.$userCustomerNumber.'", "products":'.$userProducts.'}}}); }';

if ($this->session->is_logged_in()) {
if (get_option('tulo_expose_account_id', false)) {
$userId = $this->session->get_user_id();
Expand All @@ -288,6 +292,10 @@ private function get_local_storage() {
$userEmail = "";
$userCustomerNumber = "";
$userProducts = '[]';

// set empty for now
return ' if (window.localStorage) { localStorage.setItem("tulo.account_name", "'.$userName.'"); localStorage.setItem("tulo.account_email", "'.$userEmail.'"); localStorage.setItem("tulo.account_customer_number", "'.$userCustomerNumber.'"); localStorage.setItem("tulo.account_id", "'.$userId.'"); localStorage.setItem("tulo.account_user_products", '.$userProducts.'); }';

if ($this->session->is_logged_in()) {
if (get_option('tulo_expose_account_id', false)) {
$userId = $this->session->get_user_id();
Expand Down
3 changes: 1 addition & 2 deletions wp-tulo-payway.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
* that starts the plugin.
*
* @link https://adeprimo.se
* @since 1.2.3.4
* @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. Now with support for Tulo Paywall.
* Version: 1.2.3.4
* Version: 1.2.5-session
* Author: Adeprimo AB
* Author URI: https://adeprimo.se
* Text Domain: tulo
Expand Down

0 comments on commit bf81c73

Please sign in to comment.