Permalink
Browse files

Merge pull request #7 from IoraHealth/pr-update-js-files-from-icis

Update authorization to reflect what works in ICIS
  • Loading branch information...
2 parents 3a98dff + dc020f3 commit bdaeb5af3797cce74824d605793d17094e988ac0 @patricksrobertson patricksrobertson committed Mar 30, 2012
@@ -3,6 +3,7 @@ this.BackboneSync = this.BackboneSync || {};
BackboneSync.FayeAuthorization = (function() {
function FayeAuthorization(options) {
this.authToken = options.auth_token;
+ this.channel = "/sync/" + options.channel;
}
FayeAuthorization.prototype.outgoing = function(message, callback) {
@@ -14,10 +15,14 @@ BackboneSync.FayeAuthorization = (function() {
message['ext'] = {}
}
- message['ext']['authToken'] = this.authToken;
+ if(message['subscription'] !== this.channel) {
+ return callback(message);
+ }
+ message['ext']['authToken'] = this.authToken;
return callback(message);
};
return FayeAuthorization;
})();
+
@@ -6,10 +6,9 @@ BackboneSync.RailsFayeSubscriber = (function() {
this.client = options.client;
this.channel = options.channel;
this.useAuthorization = options.use_authorization;
- this.authToken = options.auth_token;
if (this.useAuthorization === true) {
- outgoingAuth = new BackboneSync.FayeAuthorization({ auth_token: options.auth_token });
+ outgoingAuth = new BackboneSync.FayeAuthorization({ auth_token: options.auth_token , channel: this.channel});
this.client.addExtension(outgoingAuth);
}

0 comments on commit bdaeb5a

Please sign in to comment.