32ce5518 by Adam Heath

Add some code to wrap the Backbone.sync method, to add ?sessionId to a

url.
1 parent a6367ec8
......@@ -32,6 +32,19 @@ define(function(require) {
return deferred;
}
var authSync = function authSync(origSync, method, model, options) {
var args = _.toArray(arguments);
args.shift();
var url = options.url || _.result(model, 'url');
if (url) {
var sessionId = app.get('auth').get('sessionId');
if (sessionId) {
options.url = url + (url.indexOf('?') == -1 ? '?' : '&') + 'sessionId=' + sessionId;
}
}
return origSync.apply(this, args);
};
var FacebookProvider = Backbone.Model.extend({
initialize: function(data, globalOptions) {
// early facebook javascript load
......@@ -255,6 +268,15 @@ define(function(require) {
}, {
FacebookProvider: FacebookProvider,
FormProvider: FormProvider,
wrapSync: function(origSync) {
return function() {
return authSync.apply(this, [origSync].concat(_.toArray(arguments)));
};
},
syncMixin: function(Class) {
Class.prototype.sync = Auth.wrapSync(Class.prototype.sync);
return Class;
},
});
return Auth;
});
......