Skip to content

Commit

Permalink
add token and key to URLs only if using trello client
Browse files Browse the repository at this point in the history
  • Loading branch information
nicgirault committed Nov 28, 2015
1 parent 1ce89f9 commit 400512a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-trello-api-client",
"homepage": "https://github.com/nicgirault/angular-trello-api-client",
"version": "1.0.0",
"version": "1.0.2",
"authors": [
"nicgirault <nic.girault@gmail.com>"
],
Expand Down
8 changes: 6 additions & 2 deletions dist/angular-trello-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ angular.module('angular-trello-api-client').constant('TrelloClientConfig', {
intentEndpoint: 'https://trello.com',
version: 1,
tokenExpiration: 'never',
scope: ['read', 'write'],
scope: ['read', 'write', 'account'],
localStoragePrefix: 'trello'
});

Expand All @@ -17,7 +17,7 @@ angular.module('angular-trello-api-client').factory('TrelloInterceptor', [
return {
request: function(request) {
var token, tokenName;
if (request.skipAuthorization) {
if (!request.trelloRequest) {
return request;
}
if (shared.isAuthenticated()) {
Expand Down Expand Up @@ -80,6 +80,10 @@ angular.module('angular-trello-api-client').provider('TrelloClient', function($a
ref = ['get', 'post', 'put', 'delete'];
fn = function(method) {
return TrelloClient[method] = function(endpoint, config) {
if (config == null) {
config = {};
}
config.trelloRequest = true;
if (!$auth.isAuthenticated()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-trello-api-client",
"version": "1.0.0",
"version": "1.0.2",
"description": "",
"main": "gulpfile.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ angular.module 'angular-trello-api-client'
intentEndpoint: 'https://trello.com'
version: 1
tokenExpiration: 'never'
scope: ['read', 'write']
scope: ['read', 'write', 'account']
localStoragePrefix: 'trello'
}
4 changes: 2 additions & 2 deletions src/interceptor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ angular.module 'angular-trello-api-client'
'TrelloClientConfig'
($q, config, storage, shared, TrelloClientConfig) ->
request: (request) ->
if request.skipAuthorization
return request
return request unless request.trelloRequest

if shared.isAuthenticated()
tokenName = if config.tokenPrefix then config.tokenPrefix + '_' + config.tokenName else config.tokenName
token = storage.get tokenName
Expand Down
2 changes: 2 additions & 0 deletions src/provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ angular.module 'angular-trello-api-client'
for method in ['get', 'post', 'put', 'delete']
do (method) ->
TrelloClient[method] = (endpoint, config) ->
config ?= {}
config.trelloRequest = true # for interceptor
return unless $auth.isAuthenticated()
$http[method] baseURL + endpoint, config

Expand Down

0 comments on commit 400512a

Please sign in to comment.