Skip to content

Instantly share code, notes, and snippets.

@lloydwatkin
Created January 17, 2013 15:42
Show Gist options
  • Save lloydwatkin/4556860 to your computer and use it in GitHub Desktop.
Save lloydwatkin/4556860 to your computer and use it in GitHub Desktop.
Hack to backbone.js to get buddycloud webclient + http api server + tigase (+ buddycloud java server) talking.
@@ -1418,9 +1419,18 @@
// Make the request, allowing the user to override any Ajax options.
return Backbone.ajax(_.extend(params, options));
};
-
+var credentials;
// Set the default implementation of `Backbone.ajax` to proxy through to `$`.
Backbone.ajax = function() {
+ if (arguments[0].credentials) {
+ console.log("Storing credentials", arguments[0].credentials);
+ credentials = arguments[0].credentials;
+ } else if (credentials) {
+ arguments[0].credentials = credentials;
+ arguments[0].xhrFields = {withCredentials: true}
+ console.log("Setting credentials", arguments);
+ }
return Backbone.$.ajax.apply(Backbone.$, arguments);
};
@lloydwatkin
Copy link
Author

I never seem to get the X-Session-Id set by the webclient, i.e. loads-and-loads-and-loads of new sessions!

^^^^^ this may be a consequence of hack

@imaginator
Copy link

sessionID stuff is a bit broken right now. There's an issue open for addressing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment