Skip to content

Commit

Permalink
console.warn if no token/invalid token is specified in setToken()
Browse files Browse the repository at this point in the history
  • Loading branch information
sahat committed Oct 21, 2015
1 parent 14846af commit 41b25f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion satellizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
};

Shared.setToken = function(response) {
if (!response) {
return console.warn('Can\'t set token without passing a value');
}

var accessToken = response && response.access_token;
var token;

Expand All @@ -313,7 +317,7 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex

if (!token) {
var tokenPath = config.tokenRoot ? config.tokenRoot + '.' + config.tokenName : config.tokenName;
throw new Error('Expecting a token named "' + tokenPath + '" but instead got: ' + JSON.stringify(response.data));
return console.warn('Expecting a token named "' + tokenPath);
}

storage.set(tokenName, token);
Expand Down
Loading

0 comments on commit 41b25f5

Please sign in to comment.