Skip to content

Commit

Permalink
#76 further changes for REST support
Browse files Browse the repository at this point in the history
  • Loading branch information
itayw committed May 9, 2014
1 parent 2d5769e commit 5812992
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions bin/joola.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Object.defineProperty(joolaio, 'APITOKEN', {

joolaio.dispatch.users.verifyAPIToken(joolaio.APITOKEN, function (err, user) {
joolaio.USER = user;
joolaio.TOKEN = user.token._;
//joolaio.TOKEN = user.token._;
});
}
});
Expand Down Expand Up @@ -237,9 +237,8 @@ joolaio.init = function (options, callback) {

joolaio.dispatch.users.verifyAPIToken(joolaio._apitoken, function (err, user) {
joolaio.USER = user;
joolaio.TOKEN = user.token._;

joolaio.events.emit('core.init.finish');
joolaio.events.emit('ready');
if (typeof callback === 'function')
return callback(null, joolaio);
});
Expand Down Expand Up @@ -289,9 +288,9 @@ joolaio.set = function (key, value, callback) {
return callback(new Error('Failed to verify API Token'));

joolaio.USER = user;
joolaio.TOKEN = user.token._;
if (typeof callback === 'function')
if (typeof callback === 'function'){
return callback(null);
}
});
}
else if (key === 'token') {
Expand Down Expand Up @@ -1050,7 +1049,8 @@ api.getJSON = function (options, objOptions, callback) {

var routeID = options.path + '-' + joolaio.common.uuid();

objOptions._token = joolaio.TOKEN;
if (joolaio.TOKEN)
objOptions._token = joolaio.TOKEN;
if (!objOptions._token)
objOptions.APIToken = joolaio.APITOKEN;
objOptions._path = options.path;
Expand Down
2 changes: 1 addition & 1 deletion bin/joola.io.min.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Object.defineProperty(joolaio, 'APITOKEN', {

joolaio.dispatch.users.verifyAPIToken(joolaio.APITOKEN, function (err, user) {
joolaio.USER = user;
joolaio.TOKEN = user.token._;
//joolaio.TOKEN = user.token._;
});
}
});
Expand Down Expand Up @@ -235,9 +235,8 @@ joolaio.init = function (options, callback) {

joolaio.dispatch.users.verifyAPIToken(joolaio._apitoken, function (err, user) {
joolaio.USER = user;
joolaio.TOKEN = user.token._;

joolaio.events.emit('core.init.finish');
joolaio.events.emit('ready');
if (typeof callback === 'function')
return callback(null, joolaio);
});
Expand Down Expand Up @@ -287,9 +286,9 @@ joolaio.set = function (key, value, callback) {
return callback(new Error('Failed to verify API Token'));

joolaio.USER = user;
joolaio.TOKEN = user.token._;
if (typeof callback === 'function')
if (typeof callback === 'function'){
return callback(null);
}
});
}
else if (key === 'token') {
Expand Down
3 changes: 2 additions & 1 deletion lib/common/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ api.getJSON = function (options, objOptions, callback) {

var routeID = options.path + '-' + joolaio.common.uuid();

objOptions._token = joolaio.TOKEN;
if (joolaio.TOKEN)
objOptions._token = joolaio.TOKEN;
if (!objOptions._token)
objOptions.APIToken = joolaio.APITOKEN;
objOptions._path = options.path;
Expand Down

0 comments on commit 5812992

Please sign in to comment.