Plugin Directory

Changeset 1711815


Ignore:
Timestamp:
08/10/2017 10:38:10 PM (9 years ago)
Author:
paulq
Message:

SSO session validation

Location:
chatwee/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • chatwee/trunk/chatwee.php

    r1595247 r1711815  
    7373
    7474        dbDelta($create_pages_to_display_table_clause);
    75        
     75
    7676
    7777        update_option("chatwee_settings", get_default_chatwee_settings());
     
    8282
    8383        $id = get_the_ID();
    84        
     84
    8585        $categories_to_display = $chatwee_settings["categories_to_display"];
    86        
     86
    8787        $main_page_matched = is_array($categories_to_display) && in_array("main_page", $categories_to_display) && is_home() === true;
    8888        $search_page_matched = is_array($categories_to_display) && in_array("search_page", $categories_to_display) && is_search() === true;
     
    157157        }
    158158
    159         if($chatwee_settings["enable_sso"] === true && is_user_logged_in() === true && ChatweeV2_Session::isSessionSet() === false) {
    160             login_v2(wp_get_current_user());
     159        try {
     160            if($chatwee_settings["enable_sso"] === true && is_user_logged_in() === true) {
     161                if(ChatweeV2_Session::isSessionSet() === false) {
     162                    login_v2(wp_get_current_user());
     163                } else {
     164                    $sessionId = ChatweeV2_Session::getSessionId();
     165
     166                    $isSessionValid = ChatweeV2_SsoUser::validateSession(Array(
     167                        "sessionId" => $sessionId
     168                    ));
     169
     170                    if($isSessionValid === false) {
     171                        login_v2(wp_get_current_user());
     172                    }
     173                }
     174            }
     175        } catch(Exception $exception) {
     176            add_log("Error while reinitializng SSO session: " . $exception->getMessage());
    161177        }
    162178    }
    163179
    164180    function init_handler() {
     181        if(wp_doing_ajax() === true) {
     182            return false;
     183        }
     184
    165185        $chatwee_settings = get_option("chatwee_settings");
    166186
     
    178198        $chatwee_settings = get_option("chatwee_settings");
    179199
    180         if(ChatweeV1_User::isLogged() === false && $chatwee_settings["disable_offline_users"] === true) {
     200        if(is_user_logged_in() === false && $chatwee_settings["disable_offline_users"] === true) {
    181201            return false;
    182202        }
     
    189209        $chatwee_settings = get_option("chatwee_settings");
    190210
    191         if(ChatweeV2_Session::isSessionSet() === false && $chatwee_settings["disable_offline_users"] === true) {
     211        if(is_user_logged_in() === false && $chatwee_settings["disable_offline_users"] === true) {
    192212            return false;
    193213        }
     
    251271                add_log("Error: " . $exception->getMessage());
    252272            }
    253         } elseif ($has_been_promoted_as_chatwee_moderator_on_wordpress == false && $has_been_set_as_moderator_on_chatwee == 1) {   
     273        } elseif ($has_been_promoted_as_chatwee_moderator_on_wordpress == false && $has_been_set_as_moderator_on_chatwee == 1) {
    254274            try {
    255275                ChatweeV2_SsoUser::edit(Array(
     
    325345
    326346    function register_v2($user) {
    327        
     347
    328348        $username = $user->display_name ? $user->display_name : $user->user_login;
    329349
     
    382402    function user_edit_handler($user_id) {
    383403        $user = get_user_by("id", $user_id);
    384        
     404
    385405        edit_v2($user);
    386406    }
  • chatwee/trunk/lib/ChatweeV2_SDK/Chatwee/SsoUser.php

    r1595247 r1711815  
    4040    }
    4141
     42    public static function validateSession($parameters) {
     43        $requestParameters = Array(
     44            "sessionId" => $parameters["sessionId"]
     45        );
     46
     47        $httpClient = new ChatweeV2_HttpClient();
     48        $httpClient->get("sso-user/validate-session", $requestParameters);
     49
     50        $validationResponse = $httpClient->getResponseObject();
     51
     52        return $validationResponse;
     53    }
     54
    4255    public static function logout($parameters) {
    4356        $requestParameters = Array(
  • chatwee/trunk/readme.txt

    r1616245 r1711815  
    4141= Resources =
    4242*   To use the plugin, please [sign up](https://client.chatwee.com/v2/dashboard) with us first. It’s free and you’ll need access to the installation code, in order to get this plugin to work.
    43 *   [WordPress chat plugin installation instruction](https://chatwee.com/wordpress-chat-plugin-installation)   
     43*   [WordPress chat plugin installation instruction](https://chatwee.com/wordpress-chat-plugin-installation)
    4444*   [Chatwee 2.0 features](https://chatwee.com/full-features) / [Chatwee 1.0 features](https://v1.chatwee.com/features)
    4545*   [Chatwee 2.0 support center](https://chatwee.com/support) / [Chatwee 1.0 support center](https://support.chatwee.com)
Note: See TracChangeset for help on using the changeset viewer.