From 400512a0bb1ee47fb0242560c80ec81bed3ce50b Mon Sep 17 00:00:00 2001 From: nicgirault Date: Sat, 28 Nov 2015 14:00:25 +0100 Subject: [PATCH] add token and key to URLs only if using trello client --- bower.json | 2 +- dist/angular-trello-api-client.js | 8 ++++++-- package.json | 2 +- src/config.coffee | 2 +- src/interceptor.coffee | 4 ++-- src/provider.coffee | 2 ++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 1984214..1404ced 100644 --- a/bower.json +++ b/bower.json @@ -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 " ], diff --git a/dist/angular-trello-api-client.js b/dist/angular-trello-api-client.js index 6ddfdf9..f983a1b 100644 --- a/dist/angular-trello-api-client.js +++ b/dist/angular-trello-api-client.js @@ -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' }); @@ -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()) { @@ -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; } diff --git a/package.json b/package.json index 75ceb27..be532f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-trello-api-client", - "version": "1.0.0", + "version": "1.0.2", "description": "", "main": "gulpfile.js", "dependencies": { diff --git a/src/config.coffee b/src/config.coffee index a89c1fd..0f7154d 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -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' } diff --git a/src/interceptor.coffee b/src/interceptor.coffee index 9a488e7..c8dd936 100644 --- a/src/interceptor.coffee +++ b/src/interceptor.coffee @@ -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 diff --git a/src/provider.coffee b/src/provider.coffee index 07bfbfd..77e4b03 100644 --- a/src/provider.coffee +++ b/src/provider.coffee @@ -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