diff --git a/client.coffee b/client.coffee index 6e156e8..0ffb721 100644 --- a/client.coffee +++ b/client.coffee @@ -32,7 +32,11 @@ class Client else if msg.cmd == 'auth' and msg.data @.authUser(msg.data) else if msg.cmd == 'subscribe' and msg.routing_key - @.addSubscription(msg.routing_key) + if msg.routing_key.indexOf("live_notifications") == 0 + userId = signing.getUserId(@.auth.token) + @.addSubscription("live_notifications.#{userId}") + else + @.addSubscription(msg.routing_key) else if msg.cmd == 'unsubscribe' and msg.routing_key @.removeSubscription(msg.routing_key) diff --git a/signing.coffee b/signing.coffee index 941e179..0fd3cf5 100644 --- a/signing.coffee +++ b/signing.coffee @@ -12,6 +12,11 @@ rsplit = (token, sep, maxsplit) -> return split +exports.getUserId = (token) -> + value = token.split(':')[0] + value = JSON.parse(base64url.decode(value)) + return value.user_authentication_id + exports.verify = (token) -> [value, sig] = rsplit(token, ':', 1)