Skip to content

Commit 4109fb8

Browse files
committed
Release 4.1.0
1 parent 0f56aed commit 4109fb8

File tree

4 files changed

+62
-56
lines changed

4 files changed

+62
-56
lines changed

CHANGELOG.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
## Changelog
22

3-
### upcoming / 2016-02-12
4-
- [#80](https://github.com/seegno/angular-oauth2/pull/80) Reintroduce authorization header to be overridden (@ruipenso)
3+
### 4.1.0 / 2016-11-03
4+
- [#87](https://github.com/oauthjs/angular-oauth2/pull/87) allow overriding oauth base config using options (@lionelB)
5+
6+
### 4.0.0 / 2016-02-12
7+
- [#80](https://github.com/oauthjs/angular-oauth2/pull/80) Reintroduce authorization header to be overridden (@ruipenso)
58

69
### 3.1.1 / 2016-02-12
7-
- [#79](https://github.com/seegno/angular-oauth2/pull/79) Update dependencies (@ruipenso)
10+
- [#79](https://github.com/oauthjs/angular-oauth2/pull/79) Update dependencies (@ruipenso)
811

912
### 3.1.0 / 2016-02-10
10-
- [#78](https://github.com/seegno/angular-oauth2/pull/78) Update OAuth methods to allow `data` and `options` override (@ruipenso)
11-
- [#71](https://github.com/seegno/angular-oauth2/pull/71) Add `client_id` and `client_secret` on revoke_token (@tinogomes)
12-
- [#77](https://github.com/seegno/angular-oauth2/pull/77) Update interceptor to allow authorization header to be overridden (@ruipenso)
13-
- [#75](https://github.com/seegno/angular-oauth2/pull/75) Update README dependencies (@ruipenso)
14-
- [#76](https://github.com/seegno/angular-oauth2/pull/76) Update `package.json` (@ruipenso)
13+
- [#78](https://github.com/oauthjs/angular-oauth2/pull/78) Update OAuth methods to allow `data` and `options` override (@ruipenso)
14+
- [#71](https://github.com/oauthjs/angular-oauth2/pull/71) Add `client_id` and `client_secret` on revoke_token (@tinogomes)
15+
- [#77](https://github.com/oauthjs/angular-oauth2/pull/77) Update interceptor to allow authorization header to be overridden (@ruipenso)
16+
- [#75](https://github.com/oauthjs/angular-oauth2/pull/75) Update README dependencies (@ruipenso)
17+
- [#76](https://github.com/oauthjs/angular-oauth2/pull/76) Update `package.json` (@ruipenso)
1518

1619
### 3.0.1 / 2015-06-01
17-
- [#27](https://github.com/seegno/angular-oauth2/pull/27) Add travis-ci configuration (@joaogranado)
20+
- [#27](https://github.com/oauthjs/angular-oauth2/pull/27) Add travis-ci configuration (@joaogranado)
1821

1922
### 3.0.0 / 2015-06-01
20-
- [#49](https://github.com/seegno/angular-oauth2/pull/49) Add changelog task (@ruipenso)
21-
- [#48](https://github.com/seegno/angular-oauth2/pull/48) Update readme (@ruipenso)
22-
- [#25](https://github.com/seegno/angular-oauth2/pull/25) Replace ipCookie with ngCookies (@joaogranado)
23-
- [#28](https://github.com/seegno/angular-oauth2/pull/28) Add methods to get/set `token` property (@joaogranado)
24-
- [#47](https://github.com/seegno/angular-oauth2/pull/47) Add unauthorized error interception (@ruipenso)
23+
- [#49](https://github.com/oauthjs/angular-oauth2/pull/49) Add changelog task (@ruipenso)
24+
- [#48](https://github.com/oauthjs/angular-oauth2/pull/48) Update readme (@ruipenso)
25+
- [#25](https://github.com/oauthjs/angular-oauth2/pull/25) Replace ipCookie with ngCookies (@joaogranado)
26+
- [#28](https://github.com/oauthjs/angular-oauth2/pull/28) Add methods to get/set `token` property (@joaogranado)
27+
- [#47](https://github.com/oauthjs/angular-oauth2/pull/47) Add unauthorized error interception (@ruipenso)
2528

2629
### 2.1.1 / 2015-05-28
27-
- [#40](https://github.com/seegno/angular-oauth2/pull/40) Fix missing dependency on readme example (@ruipenso)
30+
- [#40](https://github.com/oauthjs/angular-oauth2/pull/40) Fix missing dependency on readme example (@ruipenso)
2831

2932
### 2.1.0 / 2015-03-09
30-
- [#15](https://github.com/seegno/angular-oauth2/pull/15) Add `clientSecret` as optional (@ruipenso)
31-
- [#18](https://github.com/seegno/angular-oauth2/pull/18) Remove npm postinstall script (@ruipenso)
32-
- [#14](https://github.com/seegno/angular-oauth2/pull/14) Fix readme configuration (@ruipenso)
33+
- [#15](https://github.com/oauthjs/angular-oauth2/pull/15) Add `clientSecret` as optional (@ruipenso)
34+
- [#18](https://github.com/oauthjs/angular-oauth2/pull/18) Remove npm postinstall script (@ruipenso)
35+
- [#14](https://github.com/oauthjs/angular-oauth2/pull/14) Fix readme configuration (@ruipenso)
3336

3437
### 2.0.0 / 2015-02-04
35-
- [#11](https://github.com/seegno/angular-oauth2/pull/11) Add options to `ipCookie.remove()` on OAuthToken (@ruipenso)
36-
- [#10](https://github.com/seegno/angular-oauth2/pull/10) Update `oauthInterceptor` responseError handling (@ruipenso)
37-
- [#7](https://github.com/seegno/angular-oauth2/pull/7) Fix readme typo of download url (@brunnolou)
38-
- [#6](https://github.com/seegno/angular-oauth2/pull/6) README.md: typo fix (@AdirAmsalem)
38+
- [#11](https://github.com/oauthjs/angular-oauth2/pull/11) Add options to `ipCookie.remove()` on OAuthToken (@ruipenso)
39+
- [#10](https://github.com/oauthjs/angular-oauth2/pull/10) Update `oauthInterceptor` responseError handling (@ruipenso)
40+
- [#7](https://github.com/oauthjs/angular-oauth2/pull/7) Fix readme typo of download url (@brunnolou)
41+
- [#6](https://github.com/oauthjs/angular-oauth2/pull/6) README.md: typo fix (@AdirAmsalem)
3942

4043
### 1.0.2 / 2015-01-19
41-
- [#4](https://github.com/seegno/angular-oauth2/pull/4) Add support for higher dependencies versions (@joaogranado)
44+
- [#4](https://github.com/oauthjs/angular-oauth2/pull/4) Add support for higher dependencies versions (@joaogranado)
4245

4346
### 1.0.1 / 2015-01-19
44-
- [#3](https://github.com/seegno/angular-oauth2/pull/3) Fix bower ignore list (@ruipenso)
47+
- [#3](https://github.com/oauthjs/angular-oauth2/pull/3) Fix bower ignore list (@ruipenso)
4548

4649
### 1.0.0 / 2015-01-18
47-
- [#2](https://github.com/seegno/angular-oauth2/pull/2) Fix indentation in README examples (@fixe)
48-
- [#1](https://github.com/seegno/angular-oauth2/pull/1) Add project structure (@ruipenso)
50+
- [#2](https://github.com/oauthjs/angular-oauth2/pull/2) Fix indentation in README examples (@fixe)
51+
- [#1](https://github.com/oauthjs/angular-oauth2/pull/1) Add project structure (@ruipenso)

dist/angular-oauth2.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* angular-oauth2 - Angular OAuth2
3-
* @version v4.0.0
3+
* @version v4.1.0
44
* @link https://github.com/seegno/angular-oauth2
55
* @license MIT
66
*/
@@ -14,10 +14,6 @@
1414
}
1515
})(this, function(angular, ngCookies, queryString) {
1616
var ngModule = angular.module("angular-oauth2", [ ngCookies ]).config(oauthConfig).factory("oauthInterceptor", oauthInterceptor).provider("OAuth", OAuthProvider).provider("OAuthToken", OAuthTokenProvider);
17-
function oauthConfig($httpProvider) {
18-
$httpProvider.interceptors.push("oauthInterceptor");
19-
}
20-
oauthConfig.$inject = [ "$httpProvider" ];
2117
function oauthInterceptor($q, $rootScope, OAuthToken) {
2218
return {
2319
request: function request(config) {
@@ -40,6 +36,10 @@
4036
};
4137
}
4238
oauthInterceptor.$inject = [ "$q", "$rootScope", "OAuthToken" ];
39+
function oauthConfig($httpProvider) {
40+
$httpProvider.interceptors.push("oauthInterceptor");
41+
}
42+
oauthConfig.$inject = [ "$httpProvider" ];
4343
var _createClass = function() {
4444
function defineProperties(target, props) {
4545
for (var i = 0; i < props.length; i++) {
@@ -70,15 +70,12 @@
7070
};
7171
var requiredKeys = [ "baseUrl", "clientId", "grantPath", "revokePath" ];
7272
function OAuthProvider() {
73-
var config;
74-
this.configure = function(params) {
75-
if (config) {
76-
throw new Error("Already configured.");
77-
}
73+
var _this = this;
74+
var sanitizeConfigParams = function sanitizeConfigParams(params) {
7875
if (!(params instanceof Object)) {
7976
throw new TypeError("Invalid argument: `config` must be an `Object`.");
8077
}
81-
config = angular.extend({}, defaults, params);
78+
var config = angular.extend({}, defaults, params);
8279
angular.forEach(requiredKeys, function(key) {
8380
if (!config[key]) {
8481
throw new Error("Missing parameter: " + key + ".");
@@ -95,15 +92,21 @@
9592
}
9693
return config;
9794
};
95+
this.configure = function(params) {
96+
_this.defaultConfig = sanitizeConfigParams(params);
97+
};
9898
this.$get = function($http, OAuthToken) {
9999
var OAuth = function() {
100-
function OAuth() {
100+
function OAuth(config) {
101101
_classCallCheck(this, OAuth);
102-
if (!config) {
103-
throw new Error("`OAuthProvider` must be configured first.");
104-
}
102+
this.config = config;
105103
}
106104
_createClass(OAuth, [ {
105+
key: "configure",
106+
value: function configure(params) {
107+
this.config = sanitizeConfigParams(params);
108+
}
109+
}, {
107110
key: "isAuthenticated",
108111
value: function isAuthenticated() {
109112
return !!OAuthToken.getToken();
@@ -112,11 +115,11 @@
112115
key: "getAccessToken",
113116
value: function getAccessToken(data, options) {
114117
data = angular.extend({
115-
client_id: config.clientId,
118+
client_id: this.config.clientId,
116119
grant_type: "password"
117120
}, data);
118-
if (null !== config.clientSecret) {
119-
data.client_secret = config.clientSecret;
121+
if (null !== this.config.clientSecret) {
122+
data.client_secret = this.config.clientSecret;
120123
}
121124
data = queryString.stringify(data);
122125
options = angular.extend({
@@ -125,7 +128,7 @@
125128
"Content-Type": "application/x-www-form-urlencoded"
126129
}
127130
}, options);
128-
return $http.post("" + config.baseUrl + config.grantPath, data, options).then(function(response) {
131+
return $http.post("" + this.config.baseUrl + this.config.grantPath, data, options).then(function(response) {
129132
OAuthToken.setToken(response.data);
130133
return response;
131134
});
@@ -134,12 +137,12 @@
134137
key: "getRefreshToken",
135138
value: function getRefreshToken(data, options) {
136139
data = angular.extend({
137-
client_id: config.clientId,
140+
client_id: this.config.clientId,
138141
grant_type: "refresh_token",
139142
refresh_token: OAuthToken.getRefreshToken()
140143
}, data);
141-
if (null !== config.clientSecret) {
142-
data.client_secret = config.clientSecret;
144+
if (null !== this.config.clientSecret) {
145+
data.client_secret = this.config.clientSecret;
143146
}
144147
data = queryString.stringify(data);
145148
options = angular.extend({
@@ -148,7 +151,7 @@
148151
"Content-Type": "application/x-www-form-urlencoded"
149152
}
150153
}, options);
151-
return $http.post("" + config.baseUrl + config.grantPath, data, options).then(function(response) {
154+
return $http.post("" + this.config.baseUrl + this.config.grantPath, data, options).then(function(response) {
152155
OAuthToken.setToken(response.data);
153156
return response;
154157
});
@@ -158,28 +161,28 @@
158161
value: function revokeToken(data, options) {
159162
var refreshToken = OAuthToken.getRefreshToken();
160163
data = angular.extend({
161-
client_id: config.clientId,
164+
client_id: this.config.clientId,
162165
token: refreshToken ? refreshToken : OAuthToken.getAccessToken(),
163166
token_type_hint: refreshToken ? "refresh_token" : "access_token"
164167
}, data);
165-
if (null !== config.clientSecret) {
166-
data.client_secret = config.clientSecret;
168+
if (null !== this.config.clientSecret) {
169+
data.client_secret = this.config.clientSecret;
167170
}
168171
data = queryString.stringify(data);
169172
options = angular.extend({
170173
headers: {
171174
"Content-Type": "application/x-www-form-urlencoded"
172175
}
173176
}, options);
174-
return $http.post("" + config.baseUrl + config.revokePath, data, options).then(function(response) {
177+
return $http.post("" + this.config.baseUrl + this.config.revokePath, data, options).then(function(response) {
175178
OAuthToken.removeToken();
176179
return response;
177180
});
178181
}
179182
} ]);
180183
return OAuth;
181184
}();
182-
return new OAuth();
185+
return new OAuth(this.defaultConfig);
183186
};
184187
this.$get.$inject = [ "$http", "OAuthToken" ];
185188
}

0 commit comments

Comments
 (0)