Plugin Directory

Changeset 2644077


Ignore:
Timestamp:
12/14/2021 06:10:07 PM (4 years ago)
Author:
templeweb3
Message:

Session fix

Location:
temple-lock/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • temple-lock/trunk/.git/FETCH_HEAD

    r2642798 r2644077  
    1 0b530117af665ae3f51d017c34e058023bde618a        branch 'master' of bitbucket.org:iclicksee/temple-wordpress
     114e45e400b5ce17366c99d9ded76a49222c87ecc        branch 'master' of bitbucket.org:iclicksee/temple-wordpress
    22e703fbb0eeb84681556060bfaa7de05ed607248c    not-for-merge   branch 'nick_rubitva' of bitbucket.org:iclicksee/temple-wordpress
    3368841ee4e122983de330b94bc5c69dc249d4e6bb    not-for-merge   branch 'temple-wp-updates' of bitbucket.org:iclicksee/temple-wordpress
  • temple-lock/trunk/.git/ORIG_HEAD

    r2642798 r2644077  
    1 a4f2aecac0c8d3f7cd774717a92d51d97b5f5344
     10b530117af665ae3f51d017c34e058023bde618a
  • temple-lock/trunk/.git/logs/HEAD

    r2642798 r2644077  
    995ebaab32419a3558484470f8db66f36b082a2dc4 a4f2aecac0c8d3f7cd774717a92d51d97b5f5344 Sean Facer <facer.sean@gmail.com> 1639229222 +0000    pull: Fast-forward
    1010a4f2aecac0c8d3f7cd774717a92d51d97b5f5344 0b530117af665ae3f51d017c34e058023bde618a Sean Facer <facer.sean@gmail.com> 1639229783 +0000    pull: Fast-forward
     110b530117af665ae3f51d017c34e058023bde618a 14e45e400b5ce17366c99d9ded76a49222c87ecc Sean Facer <facer.sean@gmail.com> 1639505381 +0000    pull: Fast-forward
  • temple-lock/trunk/.git/logs/refs/heads/master

    r2642798 r2644077  
    995ebaab32419a3558484470f8db66f36b082a2dc4 a4f2aecac0c8d3f7cd774717a92d51d97b5f5344 Sean Facer <facer.sean@gmail.com> 1639229222 +0000    pull: Fast-forward
    1010a4f2aecac0c8d3f7cd774717a92d51d97b5f5344 0b530117af665ae3f51d017c34e058023bde618a Sean Facer <facer.sean@gmail.com> 1639229783 +0000    pull: Fast-forward
     110b530117af665ae3f51d017c34e058023bde618a 14e45e400b5ce17366c99d9ded76a49222c87ecc Sean Facer <facer.sean@gmail.com> 1639505381 +0000    pull: Fast-forward
  • temple-lock/trunk/.git/refs/heads/master

    r2642798 r2644077  
    1 0b530117af665ae3f51d017c34e058023bde618a
     114e45e400b5ce17366c99d9ded76a49222c87ecc
  • temple-lock/trunk/includes/Base/ContentLock.php

    r2642796 r2644077  
    3232    function checkAuthToken()
    3333    {
    34         session_start();
    35         if (isset($_GET['oauthToken'])) {
     34        if( ! session_id() ) {
     35            session_start();
     36        }
     37        if (isset($_GET['oauthToken']) && !isset($_SESSION['RALLY_USER_ID'])) {
    3638            $_SESSION['OAUTH_TOKEN'] = sanitize_text_field($_GET['oauthToken']);
    3739        }
    38         session_write_close();
    3940    }
    4041
     
    154155    public function frontend_content_lock($content)
    155156    {
     157
    156158        /** Not Working - need to get and set Rally ID, also need to get which COIN they are using and update the lock text where
    157159         * it says $COIN (check if $_SESSION['COIN'] and display)
     
    159161        global $wp;
    160162        global $post;
     163       
    161164        if ($post->ID) {
     165
     166            $number_of_coins = get_post_meta($post->ID, 'number_of_coins_required', true);
    162167
    163168            $media_id_meta = get_post_meta($post->ID, 'hide_content_checkbox_check', true);
    164169            if ($media_id_meta == 'yes') {
    165                
    166170                if (!isset($_SESSION['COIN'])) {
    167171                    $defaultCoin = get_option('_temple_lock_user_default_coin', true);
    168172                    $_SESSION['COIN'] = $defaultCoin;
    169173                }
    170                 $number_of_coins = get_post_meta($post->ID, 'number_of_coins_required', true);
    171                 if (isset($_SESSION['OAUTH_TOKEN'])) {
     174                if (!isset($_SESSION['RALLY_USER_ID']) && isset($_SESSION['OAUTH_TOKEN']) ) {
    172175                    $params = [
    173176                        "code" => sanitize_text_field($_SESSION['OAUTH_TOKEN'])
     
    188191                    if (wp_remote_retrieve_response_code($response) == 200) {
    189192                        $apiBody     = json_decode(wp_remote_retrieve_body($response), true);
    190                         $_SESSION['RALLY_USER_ID'] = $apiBody['rnbUserId'];
     193                        if (!isset($_SESSION['RALLY_USER_ID']) &&  isset($apiBody['rnbUserId'])){
     194                            $_SESSION['RALLY_USER_ID'] = $apiBody['rnbUserId'];
     195                        }
    191196                    }
    192197                }
     
    194199                if (isset($_SESSION['RALLY_USER_ID'])) {
    195200                   
    196                     $response = wp_remote_post(TEMPLE_API_URL . 'api/balance/' . $_SESSION['RALLY_USER_ID'] . '/' . $_SESSION['COIN'], [
     201                    $response = wp_remote_post(TEMPLE_API_URL . 'api/balance/'.$_SESSION['RALLY_USER_ID'].'/' . strtoupper($_SESSION['COIN']), [
    197202                        'method'    => 'GET',
    198203                        'headers' => [
     
    206211                        'data_format' => 'body'
    207212                    ]);
     213                   
    208214                    if (wp_remote_retrieve_response_code($response) == 200) {
    209215                        $responseBody = json_decode(wp_remote_retrieve_body($response), true);
Note: See TracChangeset for help on using the changeset viewer.