Store sessionid in store instead of in cookies.
Esse commit está contido em:
@@ -1,48 +0,0 @@
|
|||||||
// Cookies API
|
|
||||||
var cookies = {
|
|
||||||
// === {{{AjaxIM.}}}**{{{cookies.set(name, value, days)}}}** ===
|
|
||||||
//
|
|
||||||
// Sets a cookie, stringifying the JSON value upon storing it.
|
|
||||||
//
|
|
||||||
// ==== Parameters ====
|
|
||||||
// * {{{name}}} is the cookie name.\\
|
|
||||||
// * {{{value}}} is the cookie data that you would like to store.\\
|
|
||||||
// * {{{days}}} is the number of days that the cookie will be stored for.
|
|
||||||
set: function(name, value, days) {
|
|
||||||
if (days) {
|
|
||||||
var date = new Date();
|
|
||||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
||||||
var expires = "; expires=" + date.toGMTString();
|
|
||||||
} else var expires = "";
|
|
||||||
document.cookie = name + "=" + JSON.stringify(value) + expires + "; path=/";
|
|
||||||
},
|
|
||||||
|
|
||||||
// === {{{AjaxIM.}}}**{{{cookies.get(name)}}}** ===
|
|
||||||
//
|
|
||||||
// Gets a cookie, decoding the JSON value before returning the data.
|
|
||||||
//
|
|
||||||
// ==== Parameters ====
|
|
||||||
// * {{{name}}} is the cookie name that you would like to retrieve.
|
|
||||||
get: function(name) {
|
|
||||||
var nameEQ = name + "=";
|
|
||||||
var ca = document.cookie.split(';');
|
|
||||||
for(var i = 0; i < ca.length; i++) {
|
|
||||||
var c = ca[i];
|
|
||||||
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
|
||||||
if (c.indexOf(nameEQ) == 0) {
|
|
||||||
var cval = decodeURIComponent(c.substring(nameEQ.length, c.length));
|
|
||||||
try { return JSON.parse(cval); } catch (e) { return cval; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
// === {{{AjaxIM.}}}**{{{cookies.erase(name)}}}** ===
|
|
||||||
//
|
|
||||||
// Deletes a cookie.
|
|
||||||
//
|
|
||||||
// {{{name}}} is the existing cookie that you would like to delete.
|
|
||||||
erase: function(name) {
|
|
||||||
this.set(name, '', -1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+7
-2
@@ -54,6 +54,10 @@ AjaxIM = function(options, actions) {
|
|||||||
signoff: this.settings.pollServer + '/app/signoff'
|
signoff: this.settings.pollServer + '/app/signoff'
|
||||||
}, actions);
|
}, actions);
|
||||||
|
|
||||||
|
if (!store.get('sessionid')) {
|
||||||
|
store.set('sessionid', uid(40));
|
||||||
|
}
|
||||||
|
|
||||||
// If Socket.IO is available, create a socket
|
// If Socket.IO is available, create a socket
|
||||||
self.socket = null;
|
self.socket = null;
|
||||||
$.getScript(this.settings.pollServer+'/socket.io/socket.io.js', function(){
|
$.getScript(this.settings.pollServer+'/socket.io/socket.io.js', function(){
|
||||||
@@ -62,7 +66,7 @@ AjaxIM = function(options, actions) {
|
|||||||
event = $.extend(true, {}, event);
|
event = $.extend(true, {}, event);
|
||||||
self.dispatchEvent(event);
|
self.dispatchEvent(event);
|
||||||
});
|
});
|
||||||
var event = {type: 'hello', from: this.username, sessionID: cookies.get('sessionid')};
|
var event = {type: 'hello', from: store.get('user'), sessionID: store.get('sessionid')};
|
||||||
self.sendEvent(event);
|
self.sendEvent(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1502,7 +1506,7 @@ AjaxIM.request = function(url, type, data, successFunc, failureFunc, noopurl) {
|
|||||||
|
|
||||||
var jsonp = (url.substring(0, 1) !== '/');
|
var jsonp = (url.substring(0, 1) !== '/');
|
||||||
var success = false;
|
var success = false;
|
||||||
data['sessionid'] = cookies.get('sessionid');
|
data['sessionid'] = store.get('sessionid');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
data: data,
|
data: data,
|
||||||
@@ -1532,6 +1536,7 @@ AjaxIM.request = function(url, type, data, successFunc, failureFunc, noopurl) {
|
|||||||
var noopfn = function() {
|
var noopfn = function() {
|
||||||
var noopdone = false;
|
var noopdone = false;
|
||||||
var event = {type: 'noop'};
|
var event = {type: 'noop'};
|
||||||
|
event['sessionid'] = store.get('sessionid');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: noopurl,
|
url: noopurl,
|
||||||
data: event,
|
data: event,
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário