Skip to content

Commit

Permalink
Merge branch 'preprod' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tamw-wnet committed Aug 16, 2023
2 parents 9a40314 + f2e36ad commit a45fcda
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
8 changes: 5 additions & 3 deletions classes/class-PBS-LAAS-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function check_pbs_login() {
}
$updated_tokeninfo = $this->update_pbs_tokeninfo($current_tokeninfo);

$access_token = $updated_tokeninfo['access_token'];
$access_token = isset($updated_tokeninfo['access_token']) ? $updated_tokeninfo['access_token'] : false;

if (! $access_token) {
// they're not logged in
Expand Down Expand Up @@ -378,6 +378,7 @@ private function decrypt($cyphertext=''){


private function retrieve_encrypted_tokeninfo() {
$tokeninfo = false;

// check for encrypted tokeninfo in cookie
if (isset($_COOKIE[$this->tokeninfo_cookiename])){
Expand All @@ -389,8 +390,9 @@ private function retrieve_encrypted_tokeninfo() {
if ($decrypted) {
$tokeninfo = $decrypted;
}

$tokeninfo = json_decode($tokeninfo, true);
if (!empty($tokeninfo)) {
$tokeninfo = json_decode($tokeninfo, true);
}
return $tokeninfo;
}

Expand Down
9 changes: 5 additions & 4 deletions classes/class-pbs-passport-authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($file) {
$this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $file ) ) );
$this->token = 'pbs_passport_authenticate';
$this->defaults = get_option($this->token);
$this->version = '0.3.1.4';
$this->version = '0.3.1.5';

// Load public-facing style sheet and JavaScript.
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
Expand Down Expand Up @@ -89,9 +89,10 @@ public function rewrite_templates($template) {
// add pbsoauth to body classes.
public function ppa_body_classes( $classes ) {
if (!empty(get_query_var('pbsoauth'))) {
if (in_array(get_query_var('pbsoauth'), array('authenticate','callback','loginform','activate','userinfo','vppa','alreadymember'))) {
$classes[] = 'pbsoauth';
if ($classes[0] == 'home') { unset($classes[0]); }
if (in_array(get_query_var('pbsoauth'), array('authenticate','callback','loginform','activate','userinfo','vppa' ))) {
$classes[] = 'pbsoauth';
#jic the first element in $classes is 'home' remove it
if (reset($classes) == 'home') { array_shift($classes); }
}
}
return $classes;
Expand Down
2 changes: 1 addition & 1 deletion pbs-passport-authenticate.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Plugin Name: PBS Passport Authenticate
* Version: 0.3.1.4 -- push login events for GA4
* Version: 0.3.1.5 -- cleanup PHP warnings
* Plugin URI: https://github.com/tamw-wnet/pbs-passport-authenticate
* Description: PBS Passport Authenticate
* Author: William Tam, Brian Santalone
Expand Down
12 changes: 8 additions & 4 deletions templates/authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@
if (isset($_REQUEST["membership_id"])){
$mvault_id = $_REQUEST["membership_id"];
$mvaultinfo = $mvault_client->activate($mvault_id, $pbs_uid);
$errors['activate'] = $mvaultinfo['errors'];
if (isset($mvaultinfo['errors'])) {
$errors['activate'] = $mvaultinfo['errors'];
}
}
if (! isset($mvaultinfo["membership_id"])) {
// get the mvault record if available
$mvaultinfo = $mvault_client->get_membership_by_uid($pbs_uid);
$errors['byuid'] = $mvaultinfo['errors'];
$mvaultinfo = $mvault_client->get_membership_by_uid($pbs_uid);
if (isset($mvaultinfo['errors'])) {
$errors['byuid'] = $mvaultinfo['errors'];
}
}
// preset these for later cleanup
$userinfo["membership_info"] = array("offer" => null, "status" => "Off");
Expand All @@ -83,7 +87,7 @@
$vppa_links = $passport->get_oauth_links(array('scope' => 'account vppa'));
// We will now attempt to determine what the users current login_provider is
// mvault is fallback
$login_provider = !empty($mvaultinfo["pbs_profile"]["login_provider"]) ? strtolower($mvaultinfo["profile"]["pbs_login_provider"]) : false;
$login_provider = !empty($mvaultinfo["pbs_profile"]["login_provider"]) ? strtolower($mvaultinfo["pbs_profile"]["login_provider"]) : false;
if ( !in_array($login_provider, array("pbs", "google", "facebook", "apple") ) ) {
$login_provider = "pbs";
}
Expand Down

0 comments on commit a45fcda

Please sign in to comment.