Skip to content

Commit c5812e3

Browse files
author
Devendra
committed
override AUTH_KEY when subscribe gets auth key arg
1 parent 989d656 commit c5812e3

File tree

22 files changed

+592
-578
lines changed

22 files changed

+592
-578
lines changed

core/pubnub-common.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,6 @@ function PN_API(setup) {
11151115
, channel_group = args['channel_group']
11161116
, callback = callback || args['callback']
11171117
, callback = callback || args['message']
1118-
, auth_key = args['auth_key'] || AUTH_KEY
11191118
, connect = args['connect'] || function(){}
11201119
, reconnect = args['reconnect'] || function(){}
11211120
, disconnect = args['disconnect'] || function(){}
@@ -1132,6 +1131,8 @@ function PN_API(setup) {
11321131
, heartbeat_interval = args['heartbeat_interval']
11331132
, restore = args['restore'] || SUB_RESTORE;
11341133

1134+
AUTH_KEY = args['auth_key'] || AUTH_KEY;
1135+
11351136
// Restore Enabled?
11361137
SUB_RESTORE = restore;
11371138

@@ -1194,7 +1195,7 @@ function PN_API(setup) {
11941195
if (noheresync) return;
11951196
SELF['here_now']({
11961197
'channel' : channel,
1197-
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : auth_key }),
1198+
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : AUTH_KEY }),
11981199
'callback' : function(here) {
11991200
each( 'uuids' in here ? here['uuids'] : [],
12001201
function(uid) { presence( {
@@ -1234,7 +1235,7 @@ function PN_API(setup) {
12341235
'channel_group' : channel_group + PRESENCE_SUFFIX,
12351236
'callback' : presence,
12361237
'restore' : restore,
1237-
'auth_key' : auth_key
1238+
'auth_key' : AUTH_KEY
12381239
});
12391240

12401241
// Presence Subscribed?
@@ -1244,7 +1245,7 @@ function PN_API(setup) {
12441245
if (noheresync) return;
12451246
SELF['here_now']({
12461247
'channel_group' : channel_group,
1247-
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : auth_key }),
1248+
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : AUTH_KEY }),
12481249
'callback' : function(here) {
12491250
each( 'uuids' in here ? here['uuids'] : [],
12501251
function(uid) { presence( {
@@ -1321,7 +1322,7 @@ function PN_API(setup) {
13211322
// Connect to PubNub Subscribe Servers
13221323
_reset_offline();
13231324

1324-
var data = _get_url_params({ 'uuid' : UUID, 'auth' : auth_key });
1325+
var data = _get_url_params({ 'uuid' : UUID, 'auth' : AUTH_KEY });
13251326

13261327
if (channel_groups) {
13271328
data['channel-group'] = channel_groups;

modern/pubnub.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,6 @@ function PN_API(setup) {
11161116
, channel_group = args['channel_group']
11171117
, callback = callback || args['callback']
11181118
, callback = callback || args['message']
1119-
, auth_key = args['auth_key'] || AUTH_KEY
11201119
, connect = args['connect'] || function(){}
11211120
, reconnect = args['reconnect'] || function(){}
11221121
, disconnect = args['disconnect'] || function(){}
@@ -1133,6 +1132,8 @@ function PN_API(setup) {
11331132
, heartbeat_interval = args['heartbeat_interval']
11341133
, restore = args['restore'] || SUB_RESTORE;
11351134

1135+
AUTH_KEY = args['auth_key'] || AUTH_KEY;
1136+
11361137
// Restore Enabled?
11371138
SUB_RESTORE = restore;
11381139

@@ -1195,7 +1196,7 @@ function PN_API(setup) {
11951196
if (noheresync) return;
11961197
SELF['here_now']({
11971198
'channel' : channel,
1198-
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : auth_key }),
1199+
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : AUTH_KEY }),
11991200
'callback' : function(here) {
12001201
each( 'uuids' in here ? here['uuids'] : [],
12011202
function(uid) { presence( {
@@ -1235,7 +1236,7 @@ function PN_API(setup) {
12351236
'channel_group' : channel_group + PRESENCE_SUFFIX,
12361237
'callback' : presence,
12371238
'restore' : restore,
1238-
'auth_key' : auth_key
1239+
'auth_key' : AUTH_KEY
12391240
});
12401241

12411242
// Presence Subscribed?
@@ -1245,7 +1246,7 @@ function PN_API(setup) {
12451246
if (noheresync) return;
12461247
SELF['here_now']({
12471248
'channel_group' : channel_group,
1248-
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : auth_key }),
1249+
'data' : _get_url_params({ 'uuid' : UUID, 'auth' : AUTH_KEY }),
12491250
'callback' : function(here) {
12501251
each( 'uuids' in here ? here['uuids'] : [],
12511252
function(uid) { presence( {
@@ -1322,7 +1323,7 @@ function PN_API(setup) {
13221323
// Connect to PubNub Subscribe Servers
13231324
_reset_offline();
13241325

1325-
var data = _get_url_params({ 'uuid' : UUID, 'auth' : auth_key });
1326+
var data = _get_url_params({ 'uuid' : UUID, 'auth' : AUTH_KEY });
13261327

13271328
if (channel_groups) {
13281329
data['channel-group'] = channel_groups;

0 commit comments

Comments
 (0)