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

Commit 5d9bf83

Browse files
committed
added global logout
1 parent c6634b3 commit 5d9bf83

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

app/services/tcAuth.service.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
angular.module('tc.services').factory('TcAuthService', TcAuthService);
55

6-
TcAuthService.$inject = ['CONSTANTS', 'auth', 'AuthTokenService', '$rootScope', '$q', '$log', '$timeout', 'UserService', 'Helpers', 'ApiService', 'store'];
6+
TcAuthService.$inject = ['CONSTANTS', 'auth', 'AuthTokenService', '$rootScope', '$q', '$log', '$timeout', 'UserService', 'Helpers', 'ApiService', 'store', '$http'];
77

8-
function TcAuthService(CONSTANTS, auth, AuthTokenService, $rootScope, $q, $log, $timeout, UserService, Helpers, ApiService, store) {
8+
function TcAuthService(CONSTANTS, auth, AuthTokenService, $rootScope, $q, $log, $timeout, UserService, Helpers, ApiService, store, $http) {
99
$log = $log.getInstance("TcAuthServicetcAuth");
10+
var restangular = ApiService.restangularV3;
1011
var auth0 = auth;
12+
var apiUrl = CONSTANTS.API_URL_V3;
1113
var service = {
1214
login: login,
1315
socialLogin: socialLogin,
@@ -162,6 +164,19 @@
162164
}
163165

164166
function logout() {
167+
$http({
168+
url: apiUrl + '/authorizations/1',
169+
method: 'DELETE',
170+
headers: {
171+
'Authorization': "Bearer " + AuthTokenService.getV3Token()
172+
},
173+
data: {}
174+
}).then(function(res) {
175+
$log.log('logout successful');
176+
}).catch(function(resp) {
177+
$log.error('logout error');
178+
});
179+
165180
return $q(function(resolve, reject) {
166181
AuthTokenService.removeTokens();
167182
$rootScope.$broadcast(CONSTANTS.EVENT_USER_LOGGED_OUT);

0 commit comments

Comments
 (0)