From c7da2bba28dce1ede6585367f8c73e2423fa0e44 Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Wed, 22 Oct 2014 18:21:45 -0400 Subject: [PATCH 1/8] Broadcast event oauth:tokenDestroy after a logout --- app/scripts/directives/oauth.js | 1 + test/spec/directives/oauth.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index 08cf7c0..ad039c9 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,6 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:tokenDestroy'); loggedOut(); }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index e5e34c8..0f37632 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -137,6 +137,10 @@ describe('oauth', function() { callback = jasmine.createSpy('callback'); }); + beforeEach(function() { + $rootScope.$on('oauth:tokenDestroy', callback); + }); + beforeEach(function() { $rootScope.$on('oauth:logout', callback); }); @@ -150,9 +154,10 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:tokenDestroy and oauth:logout event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); + expect(callback.calls.count()).toBe(2); }); }); }); @@ -199,6 +204,10 @@ describe('oauth', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); + + it('does not fire the oauth:tokenDestroy event', function() { + expect(callback.calls.count()).toBe(1); + }); }); From bea3e00458ad96b3a3eb020f6a2e5c8612629a6f Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Mon, 27 Oct 2014 22:10:12 -0400 Subject: [PATCH 2/8] Broadcasting oauth:logout when a user logs out manually and oauth:loggedOut when no access token --- app/scripts/directives/oauth.js | 4 ++-- test/spec/directives/oauth.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index ad039c9..f47478d 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,7 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); - $rootScope.$broadcast('oauth:tokenDestroy'); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -86,7 +86,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index 0f37632..1d4b2de 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -138,11 +138,11 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:tokenDestroy', callback); + $rootScope.$on('oauth:logout', callback); }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -154,7 +154,7 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:tokenDestroy and oauth:logout event', function() { + it('fires the oauth:logout and oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); expect(callback.calls.count()).toBe(2); @@ -170,7 +170,7 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -200,12 +200,12 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); - it('does not fire the oauth:tokenDestroy event', function() { + it('does not fire the oauth:logout event', function() { expect(callback.calls.count()).toBe(1); }); }); From 9a79fd57bd39f2d58ee0717318808be51fc007b1 Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Wed, 22 Oct 2014 18:21:45 -0400 Subject: [PATCH 3/8] Broadcast event oauth:tokenDestroy after a logout --- app/scripts/directives/oauth.js | 1 + test/spec/directives/oauth.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index 08cf7c0..ad039c9 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,6 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:tokenDestroy'); loggedOut(); }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index e5e34c8..0f37632 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -137,6 +137,10 @@ describe('oauth', function() { callback = jasmine.createSpy('callback'); }); + beforeEach(function() { + $rootScope.$on('oauth:tokenDestroy', callback); + }); + beforeEach(function() { $rootScope.$on('oauth:logout', callback); }); @@ -150,9 +154,10 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:tokenDestroy and oauth:logout event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); + expect(callback.calls.count()).toBe(2); }); }); }); @@ -199,6 +204,10 @@ describe('oauth', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); + + it('does not fire the oauth:tokenDestroy event', function() { + expect(callback.calls.count()).toBe(1); + }); }); From 7d0566489e8da4f4b6226cb5e3283c8025e613c0 Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Mon, 27 Oct 2014 22:10:12 -0400 Subject: [PATCH 4/8] Broadcasting oauth:logout when a user logs out manually and oauth:loggedOut when no access token --- app/scripts/directives/oauth.js | 4 ++-- test/spec/directives/oauth.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index ad039c9..f47478d 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,7 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); - $rootScope.$broadcast('oauth:tokenDestroy'); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -86,7 +86,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index 0f37632..1d4b2de 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -138,11 +138,11 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:tokenDestroy', callback); + $rootScope.$on('oauth:logout', callback); }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -154,7 +154,7 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:tokenDestroy and oauth:logout event', function() { + it('fires the oauth:logout and oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); expect(callback.calls.count()).toBe(2); @@ -170,7 +170,7 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -200,12 +200,12 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); - it('does not fire the oauth:tokenDestroy event', function() { + it('does not fire the oauth:logout event', function() { expect(callback.calls.count()).toBe(1); }); }); From e0039eb820b7a91d1b0489a4076e4cf222fb855f Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Tue, 28 Oct 2014 18:00:58 -0400 Subject: [PATCH 5/8] Building dist with the new logout and loggedOut broadcasted events --- dist/oauth-ng.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/oauth-ng.js b/dist/oauth-ng.js index 1a409a0..b262f5e 100644 --- a/dist/oauth-ng.js +++ b/dist/oauth-ng.js @@ -1,4 +1,4 @@ -/* oauth-ng - v0.2.8 - 2014-10-26 */ +/* oauth-ng - v0.2.8 - 2014-10-28 */ 'use strict'; @@ -365,6 +365,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -376,7 +377,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; }; From fe7a377d29ffaec80a24beadb745662ea3e9d635 Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Wed, 22 Oct 2014 18:21:45 -0400 Subject: [PATCH 6/8] Broadcast event oauth:tokenDestroy after a logout --- app/scripts/directives/oauth.js | 1 + test/spec/directives/oauth.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index 08cf7c0..ad039c9 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,6 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:tokenDestroy'); loggedOut(); }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index e5e34c8..0f37632 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -137,6 +137,10 @@ describe('oauth', function() { callback = jasmine.createSpy('callback'); }); + beforeEach(function() { + $rootScope.$on('oauth:tokenDestroy', callback); + }); + beforeEach(function() { $rootScope.$on('oauth:logout', callback); }); @@ -150,9 +154,10 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:tokenDestroy and oauth:logout event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); + expect(callback.calls.count()).toBe(2); }); }); }); @@ -199,6 +204,10 @@ describe('oauth', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); + + it('does not fire the oauth:tokenDestroy event', function() { + expect(callback.calls.count()).toBe(1); + }); }); From 1c51932c3a8d53b0f7f9065e31cc898f936540d9 Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Mon, 27 Oct 2014 22:10:12 -0400 Subject: [PATCH 7/8] Broadcasting oauth:logout when a user logs out manually and oauth:loggedOut when no access token --- app/scripts/directives/oauth.js | 4 ++-- test/spec/directives/oauth.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/scripts/directives/oauth.js b/app/scripts/directives/oauth.js index ad039c9..f47478d 100644 --- a/app/scripts/directives/oauth.js +++ b/app/scripts/directives/oauth.js @@ -74,7 +74,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); - $rootScope.$broadcast('oauth:tokenDestroy'); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -86,7 +86,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; }; diff --git a/test/spec/directives/oauth.js b/test/spec/directives/oauth.js index 0f37632..1d4b2de 100644 --- a/test/spec/directives/oauth.js +++ b/test/spec/directives/oauth.js @@ -138,11 +138,11 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:tokenDestroy', callback); + $rootScope.$on('oauth:logout', callback); }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -154,7 +154,7 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:tokenDestroy and oauth:logout event', function() { + it('fires the oauth:logout and oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); expect(callback.calls.count()).toBe(2); @@ -170,7 +170,7 @@ describe('oauth', function() { }); beforeEach(function() { - $rootScope.$on('oauth:logout', callback); + $rootScope.$on('oauth:loggedOut', callback); }); beforeEach(function() { @@ -200,12 +200,12 @@ describe('oauth', function() { expect(element.find('.logged-in').attr('class')).toMatch('ng-hide'); }); - it('fires the oauth:logout event', function() { + it('fires the oauth:loggedOut event', function() { var event = jasmine.any(Object); expect(callback).toHaveBeenCalledWith(event); }); - it('does not fire the oauth:tokenDestroy event', function() { + it('does not fire the oauth:logout event', function() { expect(callback.calls.count()).toBe(1); }); }); From bf928653d3466b0acb06d367f2fd06f5c0e6fb19 Mon Sep 17 00:00:00 2001 From: Jean-Francois Turcot Date: Tue, 28 Oct 2014 18:00:58 -0400 Subject: [PATCH 8/8] Building dist with the new logout and loggedOut broadcasted events --- dist/oauth-ng.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/oauth-ng.js b/dist/oauth-ng.js index 1a409a0..b262f5e 100644 --- a/dist/oauth-ng.js +++ b/dist/oauth-ng.js @@ -1,4 +1,4 @@ -/* oauth-ng - v0.2.8 - 2014-10-26 */ +/* oauth-ng - v0.2.8 - 2014-10-28 */ 'use strict'; @@ -365,6 +365,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location scope.logout = function() { AccessToken.destroy(scope); + $rootScope.$broadcast('oauth:logout'); loggedOut(); }; @@ -376,7 +377,7 @@ directives.directive('oauth', function(AccessToken, Endpoint, Profile, $location // set the oauth directive to the logged-out status var loggedOut = function() { - $rootScope.$broadcast('oauth:logout'); + $rootScope.$broadcast('oauth:loggedOut'); scope.show = 'logged-out'; };