Plugin Directory

Changeset 2427153


Ignore:
Timestamp:
11/27/2020 09:47:13 AM (5 years ago)
Author:
dlecan
Message:

chore: release 8.2.3

Location:
unikname-connect
Files:
450 added
3 edited

Legend:

Unmodified
Added
Removed
  • unikname-connect/trunk/CHANGELOG.txt

    r2421450 r2427153  
     1= 8.2.3 [2020-11-27] =
     2
     3- **Changed**
     4  - Improve error logging when an error occurs with OIDC callback call
     5
    16= 8.2.2 [2020-11-19] =
    27
  • unikname-connect/trunk/readme.txt

    r2421450 r2427153  
    33Requires at least: 5.0.0
    44Tested up to: 5.5
    5 Stable tag: 8.2.2
     5Stable tag: 8.2.3
    66Requires PHP: 5.6.20
    77License: GPLv2 or later
     
    9393== Changelog ==
    9494
     95= 8.2.3 [2020-11-27] =
     96
     97- **Changed**
     98  - Improve error logging when an error occurs with OIDC callback call
     99
    95100= 8.2.2 [2020-11-19] =
    96101
     
    110115    You can customize colours and a front banner!
    111116
    112 [Full changelog is also available](CHANGELOG.txt).
     117[Full changelog is also available](https://github.com/unik-name/wordpress-unikname-connect/blob/master/CHANGELOG.txt).
  • unikname-connect/trunk/unikname_connect.php

    r2421450 r2427153  
    44Plugin URI: https://docs.unik-name.com/integration/connect/apps/wordpress/
    55Description: Integrate the famous Unikname Connect login solution into your Wordpress or WooCommerce websites.
    6 Version: 8.2.2
     6Version: 8.2.3
    77Author: Unikname
    88Author URI: https://www.unikname.com
     
    1212*/
    1313defined('ABSPATH') or die("Cheating........Uh!!");
    14 define('THE_CHAMP_SS_VERSION', '8.2.2');
     14define('THE_CHAMP_SS_VERSION', '8.2.3');
    1515
    1616if (!defined('UNIKNAME_CONNECT_SERVER')) {
     
    196196                    'client_secret' => $theChampLoginOptions['un_secret']
    197197                );
    198                 $response = wp_remote_post($url, array(
     198                $parameters = array(
    199199                    'method' => 'POST',
    200200                    'timeout' => 15,
     
    204204                    'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
    205205                    'body' => http_build_query($data_access_token)
    206                         )
    207206                );
    208                 // echo "2b";
    209                 // echo var_dump($response);
     207                $response = wp_remote_post($url, $parameters);
    210208                if(!is_wp_error($response) && isset($response['response']['code']) && 200 === $response['response']['code']){
    211                     // echo "2c";
    212209                    $body = json_decode(wp_remote_retrieve_body($response));
    213210                    if(is_object($body) && isset($body->access_token)){
    214                         // echo "2d";
    215                         // echo var_dump($body);
    216211                        // fetch profile data
    217212                        // TODO: replace this by an OIDC client
    218                         $profile = wp_remote_get(UNIKNAME_CONNECT_SERVER.'/oidc/profile', array(
    219                                 'method' => 'GET',
    220                                 'timeout' => 15,
    221                                 'headers' => array('Authorization' => "Bearer ".$body->access_token),
    222                                 )
     213                        $url = UNIKNAME_CONNECT_SERVER.'/oidc/profile';
     214                        $parameters = array(
     215                            'method' => 'GET',
     216                            'timeout' => 15,
     217                            'headers' => array('Authorization' => "Bearer ".$body->access_token),
    223218                        );
    224                         // echo "2d2";
    225                         // echo var_dump($profile);
     219                        $profile = wp_remote_get($url, $parameters);
    226220                        if(!is_wp_error($profile) && isset($profile['response']['code']) && 200 === $profile['response']['code']){
    227                             // echo "2e";
    228221                            $profileBody = json_decode(wp_remote_retrieve_body($profile));
    229222                            if(is_object($profileBody) && isset($profileBody->id) && $profileBody->id){
    230                                 // echo "2f";
    231223                                $profileBody = json_decode(json_encode($profileBody), true);
    232                                 // echo "profileBody: " . var_dump($profileBody);
    233224                                // $firstName = '';//isset($firstLastNameBody['firstName']) && isset($firstLastNameBody['firstName']['localized']) && isset($firstLastNameBody['firstName']['preferredLocale']) && isset($firstLastNameBody['firstName']['preferredLocale']['language']) && isset($firstLastNameBody['firstName']['preferredLocale']['country']) ? $firstLastNameBody['firstName']['localized'][$firstLastNameBody['firstName']['preferredLocale']['language'] . '_' . $firstLastNameBody['firstName']['preferredLocale']['country']] : '';
    234225                                // $lastName = '';//isset($firstLastNameBody['lastName']) && isset($firstLastNameBody['lastName']['localized']) && isset($firstLastNameBody['lastName']['preferredLocale']) && isset($firstLastNameBody['lastName']['preferredLocale']['language']) && isset($firstLastNameBody['lastName']['preferredLocale']['country']) ? $firstLastNameBody['lastName']['localized'][$firstLastNameBody['lastName']['preferredLocale']['language'] . '_' . $firstLastNameBody['lastName']['preferredLocale']['country']] : '';
     
    246237                                    'largeAvatar' => ''
    247238                                );
    248                                 // echo "user: " . var_dump($user);
    249239
    250240                                $profileData = the_champ_sanitize_profile_data($user, 'unikname');
    251                                 // echo "profileData: " . var_dump($profileData);
    252                                 // echo "2g";
    253241                                if(get_user_meta(esc_attr(trim($_GET['state'])), 'heateor_ss_unikname_mc_sub', true)){
    254                                     // echo "2h";
    255242                                    $profileData['mc_subscribe'] = 1;
    256243                                    delete_user_meta($uniknameAuthState, 'heateor_ss_unikname_mc_sub');
    257244                                }
    258                                 // echo "2i";
    259245                                $response = the_champ_user_auth($profileData, 'unikname', $uniknameRedirectUrl);
    260246                                if(is_array($response) && isset($response['message']) && $response['message'] == 'register' && (!isset($response['url']) || $response['url'] == '')){
    261                                     // echo "2i1";
    262247                                    $redirectTo = the_champ_get_login_redirection_url($uniknameRedirectUrl, true);
    263248                                }elseif(isset($response['message']) && $response['message'] == 'linked'){
    264                                     // echo "2i2";
    265249                                    $redirectTo = $uniknameRedirectUrl . (strpos($uniknameRedirectUrl, '?') !== false ? '&' : '?') . 'linked=1';
    266250                                }elseif(isset($response['message']) && $response['message'] == 'not linked'){
    267                                     // echo "2i3";
    268251                                    $redirectTo = $uniknameRedirectUrl . (strpos($uniknameRedirectUrl, '?') !== false ? '&' : '?') . 'linked=0';
    269252                                }elseif(isset($response['url']) && $response['url'] != ''){
    270                                     // echo "2i4";
    271253                                    $redirectTo = $response['url'];
    272254                                }else{
    273                                     // echo "2i5";
    274255                                    $redirectTo = the_champ_get_login_redirection_url($uniknameRedirectUrl);
    275256                                }
    276257                                the_champ_close_login_popup($redirectTo);
    277258                            }
     259                        } else {
     260                            error_log('Error when calling: ' . $url);
     261                            error_log('With parameters: ' . print_r($parameters, true));
     262                            error_log('Response: ' . print_r($profile, true));
    278263                        }
    279264                    }
    280                 }
    281             }
    282         }
    283     }
     265                } else {
     266                    error_log('Error when calling: ' . $url);
     267                    error_log('With parameters: ' . print_r($parameters, true));
     268                    error_log('Response: ' . print_r($response, true));
     269                }
     270            } else {
     271                error_log('User\'s state not found in user_meta: ' . $_GET['state']);
     272            }
     273           
     274            // We shouldn't get there, except if an error occurred before
     275           
     276        } else {
     277            error_log('Either "un_key" or "un_secret" or both are not set');
     278        }
     279    } // No else
    284280
    285281// 
Note: See TracChangeset for help on using the changeset viewer.