Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 0ad4ebc

Browse files
author
Parth Shah
committed
redirecting logout to home page, removing cookies etc
1 parent 27c08db commit 0ad4ebc

File tree

8 files changed

+74
-16
lines changed

8 files changed

+74
-16
lines changed

app/account/account.routes.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@
108108
},
109109
logout: {
110110
url: '/logout/',
111-
controller: ['TcAuthService', function(TcAuthService) {
112-
TcAuthService.logout();
113-
}],
111+
views: {
112+
'header@': {},
113+
'container@': {
114+
controller: 'LogoutController'
115+
},
116+
'footer@': {}
117+
},
114118
data: {
115119
authRequired: false
116120
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('tc.account').controller('LogoutController', LogoutController);
5+
6+
LogoutController.$inject = ['$log', 'TcAuthService', '$location'];
7+
8+
function LogoutController($log, TcAuthService, $location) {
9+
$log = $log.getInstance('LogoutController');
10+
11+
TcAuthService.logout()
12+
.then(function() {
13+
$log.debug("successfully logged out.");
14+
// redirect to home
15+
$location.path("/");
16+
});
17+
18+
}
19+
})();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* jshint -W117, -W030 */
2+
describe.only('Logout Controller', function() {
3+
var controller;
4+
var fakeLocation = {
5+
path: function(param) {
6+
return;
7+
}
8+
};
9+
sinon.spy(fakeLocation, "path");
10+
11+
beforeEach(function() {
12+
bard.appModule('topcoder');
13+
bard.appModule('tc.account');
14+
module('tc.account', function($provide) {
15+
$provide.value('$location', fakeLocation);
16+
});
17+
18+
bard.inject(this, '$controller', 'TcAuthService', '$location', '$q');
19+
20+
bard.mockService(TcAuthService, {
21+
logout: $q.when({}),
22+
_default: $q.when({})
23+
});
24+
25+
controller = $controller('LogoutController');
26+
});
27+
28+
bard.verifyNoOutstandingHttpRequests();
29+
30+
it('should be defined', function() {
31+
expect(controller).to.be.defined;
32+
});
33+
34+
it('should be successfully logged out', function() {
35+
expect(TcAuthService.logout).to.have.been.calledOnce;
36+
expect($location.path).to.have.been.calledWith('/');
37+
});
38+
39+
});

app/index.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ html
165165
script(src="account/account.module.js")
166166
script(src="account/account.routes.js")
167167
script(src="account/login/login.controller.js")
168+
script(src="account/logout/logout.controller.js")
168169
script(src="account/register/register.controller.js")
169170
script(src="account/reset-password/reset-password.controller.js")
170171
script(src="blocks/exception/exception.module.js")

app/layout/header/header.controller.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
vm.constants = CONSTANTS;
1212
vm.domain = CONSTANTS.domain;
1313
vm.login = TcAuthService.login;
14-
vm.logout = logout;
1514
vm.checkSubmit = checkSubmit;
1615
vm.searchTerm = '';
1716
vm.selectedGroup = selectedGroup;
@@ -65,13 +64,6 @@
6564
}
6665
}
6766

68-
function logout() {
69-
TcAuthService.logout()
70-
.then(function() {
71-
$state.go('home');
72-
});
73-
}
74-
7567
function selectedGroup() {
7668
return _.get(NavService, 'selectedTopLevelItem', null);
7769
}

app/layout/header/header.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
header-menu-item(ng-repeat="item in vm.userMenu" item="item")
5050

5151
li.submenu-item
52-
a.menu-link(ng-click="vm.logout(); main.menuVisible = vm.isAuth = false")
52+
//- a.menu-link(ng-click="vm.logout(); main.menuVisible = vm.isAuth = false")
53+
a.menu-link(ui-sref="logout")
5354
img.menu-icon(ng-src="/images/nav/exit.svg")
5455
.menu-text LOG OUT
5556

app/services/authToken.service.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('TcAuthToken Service', function() {
5858
it('should remove tokens from store & cookie"', function() {
5959
service.removeTokens();
6060
expect($cookies.remove).to.have.been.calledWith('tcjwt');
61+
expect($cookies.remove).to.have.been.calledWith('tcsso');
6162
expect(store.remove).to.be.have.been.calledWith('appiriojwt');
6263
});
6364

app/specs.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ <h1><a href="specs.html">Spec Runner</a></h1>
224224
<script src="/app/account/account.module.js"></script>
225225
<script src="/app/account/reset-password/reset-password.controller.js"></script>
226226
<script src="/app/account/register/register.controller.js"></script>
227+
<script src="/app/account/logout/logout.controller.js"></script>
227228
<script src="/app/account/login/login.controller.js"></script>
228229
<script src="/app/account/account.routes.js"></script>
229230
<!-- endinject -->
@@ -239,7 +240,6 @@ <h1><a href="specs.html">Spec Runner</a></h1>
239240
<script src="/app/my-dashboard/my-dashboard.spec.js"></script>
240241
<script src="/app/my-srms/my-srms.spec.js"></script>
241242
<script src="/app/profile/profile.controller.spec.js"></script>
242-
<script src="/app/settings/settings.spec.js"></script>
243243
<script src="/app/services/authToken.service.spec.js"></script>
244244
<script src="/app/services/challenge.service.spec.js"></script>
245245
<script src="/app/services/helpers.service.spec.js"></script>
@@ -248,17 +248,18 @@ <h1><a href="specs.html">Spec Runner</a></h1>
248248
<script src="/app/services/tcAuth.service.spec.js"></script>
249249
<script src="/app/services/user.service.spec.js"></script>
250250
<script src="/app/services/userStats.service.spec.js"></script>
251+
<script src="/app/settings/settings.spec.js"></script>
251252
<script src="/app/skill-picker/skill-picker.spec.js"></script>
253+
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
252254
<script src="/app/account/login/login.spec.js"></script>
253-
<script src="/app/account/reset-password/reset-password.spec.js"></script>
255+
<script src="/app/account/logout/logout.controller.spec.js"></script>
254256
<script src="/app/account/register/register.spec.js"></script>
255-
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
257+
<script src="/app/account/reset-password/reset-password.spec.js"></script>
256258
<script src="/app/directives/badges/badge-tooltip.spec.js"></script>
257259
<script src="/app/directives/busy-button/busy-button.directive.spec.js"></script>
258260
<script src="/app/directives/challenge-tile/challenge-tile.spec.js"></script>
259261
<script src="/app/directives/empty-state-placeholder/empty-state-placeholder.spec.js"></script>
260262
<script src="/app/directives/external-account/external-account.directive.spec.js"></script>
261-
<script src="/app/directives/empty-state-placeholder/empty-state-placeholder.spec.js"></script>
262263
<script src="/app/directives/tc-endless-paginator/tc-endless-paginator.spec.js"></script>
263264
<script src="/app/directives/tc-paginator/tc-paginator.spec.js"></script>
264265
<script src="/app/directives/tc-tabs/tc-tabs.directive.spec.js"></script>

0 commit comments

Comments
 (0)