Skip to content

Commit 7cbfdc7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into token_destroy_event
Conflicts: dist/oauth-ng.js
2 parents 2a66c41 + 0bedc94 commit 7cbfdc7

File tree

6 files changed

+164
-130
lines changed

6 files changed

+164
-130
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
4+
## 0.3.1 (November 3, 2014)
5+
6+
* Replace $timeout with $interval #50
7+
* Add broadcast “oath:profile” once profile is retrieved. #51
8+
9+
## 0.3.0 (October 30, 2014)
10+
11+
* Solved bug on access token definition from hash
12+
* Correctly running tests with E2E protractor
13+
314
## 0.2.8 (August 27, 2014)
415

516
* Fixed `expries_at` not being set in some situations

app/scripts/services/access-token.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var accessTokenService = angular.module('oauth.accessToken', ['ngStorage']);
44

5-
accessTokenService.factory('AccessToken', function($rootScope, $location, $sessionStorage, $timeout){
5+
accessTokenService.factory('AccessToken', function($rootScope, $location, $sessionStorage, $interval){
66

77
var service = {
88
token: null
@@ -25,7 +25,7 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
2525
* - takes the token from the sessionStorage
2626
*/
2727
service.set = function(){
28-
setTokenFromString($location.hash());
28+
this.setTokenFromString($location.hash());
2929

3030
//If hash is present in URL always use it, cuz its coming from oAuth2 provider redirect
3131
if(null === service.token){
@@ -54,15 +54,11 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
5454
};
5555

5656

57-
/* * * * * * * * * *
58-
* PRIVATE METHODS *
59-
* * * * * * * * * */
60-
6157
/**
6258
* Get the access token from a string and save it
6359
* @param hash
6460
*/
65-
var setTokenFromString = function(hash){
61+
service.setTokenFromString = function(hash){
6662
var params = getTokenFromString(hash);
6763

6864
if(params){
@@ -73,6 +69,11 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
7369
}
7470
};
7571

72+
73+
/* * * * * * * * * *
74+
* PRIVATE METHODS *
75+
* * * * * * * * * */
76+
7677
/**
7778
* Set the access token from the sessionStorage.
7879
*/
@@ -143,9 +144,9 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
143144
var setExpiresAtEvent = function(){
144145
var time = (new Date(service.token.expires_at))-(new Date());
145146
if(time){
146-
$timeout(function(){
147+
$interval(function(){
147148
$rootScope.$broadcast('oauth:expired', service.token)
148-
}, time)
149+
}, time, 1)
149150
}
150151
};
151152

app/scripts/services/profile.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
var profileClient = angular.module('oauth.profile', [])
44

5-
profileClient.factory('Profile', function($http, AccessToken) {
5+
profileClient.factory('Profile', function($http, AccessToken, $rootScope) {
66
var service = {};
77
var profile;
88

99
service.find = function(uri) {
1010
var promise = $http.get(uri, { headers: headers() });
11-
promise.success(function(response) { profile = response });
11+
promise.success(function(response) {
12+
profile = response;
13+
$rootScope.$broadcast('oauth:profile', profile);
14+
});
1215
return promise;
1316
};
1417

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oauth-ng",
3-
"version": "0.2.8",
3+
"version": "0.3.1",
44
"main": [
55
"dist/oauth-ng.js",
66
"dist/views/templates/default"
@@ -14,7 +14,7 @@
1414
"package.json"
1515
],
1616
"dependencies": {
17-
"angular": "~1.2.22",
17+
"angular": "~1.2.26",
1818
"ngstorage": "~0.3.0"
1919
},
2020
"devDependencies": {
@@ -23,6 +23,6 @@
2323
"timecop": "~0.1.1",
2424
"bootstrap-sass": "~3.0.2",
2525
"jquery": "~1.9.1",
26-
"angular-mocks": "~1.2.22"
26+
"angular-mocks": "~1.2.26"
2727
}
2828
}

dist/oauth-ng.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* oauth-ng - v0.2.8 - 2014-10-28 */
1+
/* oauth-ng - v0.3.0 - 2014-10-30 */
22

33
'use strict';
44

@@ -20,7 +20,7 @@ angular.module('oauth').config(['$locationProvider','$httpProvider',
2020

2121
var accessTokenService = angular.module('oauth.accessToken', ['ngStorage']);
2222

23-
accessTokenService.factory('AccessToken', function($rootScope, $location, $sessionStorage, $timeout){
23+
accessTokenService.factory('AccessToken', function($rootScope, $location, $sessionStorage, $interval){
2424

2525
var service = {
2626
token: null
@@ -43,7 +43,7 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
4343
* - takes the token from the sessionStorage
4444
*/
4545
service.set = function(){
46-
setTokenFromString($location.hash());
46+
this.setTokenFromString($location.hash());
4747

4848
//If hash is present in URL always use it, cuz its coming from oAuth2 provider redirect
4949
if(null === service.token){
@@ -72,15 +72,11 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
7272
};
7373

7474

75-
/* * * * * * * * * *
76-
* PRIVATE METHODS *
77-
* * * * * * * * * */
78-
7975
/**
8076
* Get the access token from a string and save it
8177
* @param hash
8278
*/
83-
var setTokenFromString = function(hash){
79+
service.setTokenFromString = function(hash){
8480
var params = getTokenFromString(hash);
8581

8682
if(params){
@@ -91,6 +87,11 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
9187
}
9288
};
9389

90+
91+
/* * * * * * * * * *
92+
* PRIVATE METHODS *
93+
* * * * * * * * * */
94+
9495
/**
9596
* Set the access token from the sessionStorage.
9697
*/
@@ -161,9 +162,9 @@ accessTokenService.factory('AccessToken', function($rootScope, $location, $sessi
161162
var setExpiresAtEvent = function(){
162163
var time = (new Date(service.token.expires_at))-(new Date());
163164
if(time){
164-
$timeout(function(){
165+
$interval(function(){
165166
$rootScope.$broadcast('oauth:expired', service.token)
166-
}, time)
167+
}, time, 1)
167168
}
168169
};
169170

@@ -239,13 +240,16 @@ endpointClient.factory('Endpoint', function(AccessToken, $location) {
239240

240241
var profileClient = angular.module('oauth.profile', [])
241242

242-
profileClient.factory('Profile', function($http, AccessToken) {
243+
profileClient.factory('Profile', function($http, AccessToken, $rootScope) {
243244
var service = {};
244245
var profile;
245246

246247
service.find = function(uri) {
247248
var promise = $http.get(uri, { headers: headers() });
248-
promise.success(function(response) { profile = response });
249+
promise.success(function(response) {
250+
profile = response;
251+
$rootScope.$broadcast('oauth:profile', profile);
252+
});
249253
return promise;
250254
};
251255

0 commit comments

Comments
 (0)