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

Commit cd92502

Browse files
committed
logout: clean edition
1 parent 638e906 commit cd92502

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

app/services/tcAuth.service.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
function TcAuthService(CONSTANTS, auth, AuthTokenService, $rootScope, $q, $log, $timeout, UserService, Helpers, ApiService, store, $http) {
99
$log = $log.getInstance("TcAuthServicetcAuth");
1010
var auth0 = auth;
11-
var apiUrl = CONSTANTS.API_URL_V3;
11+
var apiUrl = CONSTANTS.API_URL;
1212
var service = {
1313
login: login,
1414
socialLogin: socialLogin,
@@ -163,22 +163,28 @@
163163
}
164164

165165
function logout() {
166-
$http({
166+
// options for DELETE http call
167+
var logoutOptions = {
167168
url: apiUrl + '/authorizations/1',
168169
method: 'DELETE',
169170
headers: {
170171
'Authorization': "Bearer " + AuthTokenService.getV3Token()
171172
}
172-
}).then(function(res) {
173-
$log.log('logout successful');
174-
}).catch(function(resp) {
175-
$log.error('logout error');
176-
});
173+
};
174+
175+
// remove local token
176+
AuthTokenService.removeTokens();
177+
$rootScope.$broadcast(CONSTANTS.EVENT_USER_LOGGED_OUT);
177178

179+
// logout of all browsers
178180
return $q(function(resolve, reject) {
179-
AuthTokenService.removeTokens();
180-
$rootScope.$broadcast(CONSTANTS.EVENT_USER_LOGGED_OUT);
181-
resolve();
181+
$http(logoutOptions).then(function(res) {
182+
$log.log('logout successful');
183+
resolve();
184+
}).catch(function(resp) {
185+
$log.error('logout error');
186+
reject();
187+
});
182188
});
183189
}
184190

0 commit comments

Comments
 (0)