Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing a token system. #236

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ var ajaxChat = {
},

initConfig: function(config) {
this.token = config["token"];
this.loginChannelID = config['loginChannelID'];
this.loginChannelName = config['loginChannelName'];
this.timerRate = config['timerRate'];
this.ajaxURL = config['ajaxURL'];
this.ajaxURL = config['ajaxURL']+"&token="+config['token'];
this.baseURL = config['baseURL'];
this.regExpMediaUrl = config['regExpMediaUrl'];
this.startChatOnLoad = config['startChatOnLoad'];
Expand Down Expand Up @@ -2045,7 +2044,7 @@ var ajaxChat = {
logout: function() {
clearTimeout(this.timer);
var message = 'logout=true';
this.makeRequest(this.ajaxURL+"&token="+this.token,'POST',message);
this.makeRequest(this.ajaxURL,'POST',message);
},

handleLogout: function(url) {
Expand Down
7 changes: 6 additions & 1 deletion chat/lib/class/AJAXChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ function initSession() {
return;
}

//wee know the ip is match. now wee need to know if the token is correct.
if(!$this->getRequestVar('token') || $this->getRequestVar('token') != session_id()){
return;
}

// Logout if we receive a logout request, the chat has been closed or the userID could not be revalidated:
if($this->getRequestVar('logout') && $this->getRequestVar('token') == session_id() || !$this->isChatOpen() || !$this->revalidateUserID()) {
if($this->getRequestVar('logout') || !$this->isChatOpen() || !$this->revalidateUserID()) {
$this->logout();
return;
}
Expand Down