Permalink
Browse files

Avoid to give UAToken on WA registration process. We map using the co…

…nnection object
  • Loading branch information...
Fernando Rodriguez Sela
Fernando Rodriguez Sela committed Sep 5, 2012
1 parent e185523 commit e550d54a33cccc2c068e299e71b600040f32fb3a
Showing with 15 additions and 3 deletions.
  1. +7 −0 src/ns_ua/datamanager.js
  2. +6 −1 src/ns_ua/ws_server.js
  3. +1 −1 test/E2Etest.js
  4. +1 −1 test/app/js/push.js
View
@@ -102,6 +102,13 @@ datamanager.prototype = {
return callback(false);
},
+ /**
+ * Gets a UAToken from a given connection object
+ */
+ getUAToken: function (connection) {
+ return this.nodesConnections[connection] || null;
+ },
+
// TODO: Verify that the node exists before add the application
/**
* Register a new application
View
@@ -158,7 +158,12 @@ server.prototype = {
case "registerWA":
log.debug("WS::onWSMessage::registerWA --> Application registration message");
var appToken = crypto.hashSHA256(query.data.watoken + query.data.pbkbase64);
- dataManager.registerApplication(appToken, query.data.uatoken, query.data.pbkbase64, function(ok) {
+ if(!dataManager.getUAToken(connection)) {
+ log.error("No UAToken found for this connection !");
+ break;
+ }
+
+ dataManager.registerApplication(appToken, dataManager.getUAToken(connection), query.data.pbkbase64, function(ok) {
if (ok) {
var baseURL = require('../config.js').NS_AS.publicBaseURL;
var notifyURL = helpers.getNotificationURL(appToken);
View
@@ -97,7 +97,7 @@
},
registerWA: function registerWA() {
- var msg = '{"data": {"uatoken":"' + PushTest.token + '", "watoken": "testApp"}, "messageType":"registerWA" }';
+ var msg = '{"data": {"watoken": "testApp"}, "messageType":"registerWA" }';
PushTest.connection.sendUTF(msg.toString());
},
View
@@ -86,7 +86,7 @@ var Push = {
},
registerApp: function(uatoken, watoken, pbkbase64) {
- var msg = '{"data": {"uatoken":"' + uatoken + '", "watoken": "' + watoken + '", "pbkbase64": "' + pbkbase64 + '"}, "messageType":"registerWA" }';
+ var msg = '{"data": {"watoken": "' + watoken + '", "pbkbase64": "' + pbkbase64 + '"}, "messageType":"registerWA" }';
this.logMessage('Preparing to send: ' + msg);
if (this.checkbox.checked) {

0 comments on commit e550d54

Please sign in to comment.