adding a DELETE to /authtoken when user logs out

This commit is contained in:
jaredevantabor
2017-02-02 16:58:32 -08:00
parent 02c7f87185
commit 53208c22ec
3 changed files with 67 additions and 51 deletions

View File

@@ -15,9 +15,9 @@
*/
export default
['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', 'Store',
['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', 'Store', '$q',
'$injector',
function ($http, $rootScope, $location, $cookieStore, GetBasePath, Store,
function ($http, $rootScope, $location, $cookieStore, GetBasePath, Store, $q,
$injector) {
return {
setToken: function (token, expires) {
@@ -58,16 +58,24 @@ export default
}
});
},
deleteToken: function () {
return $http({
method: 'DELETE',
url: GetBasePath('authtoken')
});
},
logout: function () {
// the following puts our primary scope up for garbage collection, which
// should prevent content flash from the prior user.
var x,
deferred = $q.defer(),
ConfigService = $injector.get('ConfigService'),
SocketService = $injector.get('SocketService'),
scope = angular.element(document.getElementById('main-view')).scope();
this.deleteToken().then(() => {
if(scope){
scope.$destroy();
}
@@ -114,6 +122,11 @@ export default
if ($rootScope.sessionTimer) {
$rootScope.sessionTimer.clearTimers();
}
deferred.resolve();
});
return deferred.promise;
},
licenseTested: function () {

View File

@@ -142,11 +142,12 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope',
});
})
.error(function (data, status) {
Authorization.logout();
Authorization.logout().then( () => {
Wait('stop');
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', loginAgain);
});
});
});
// Call the API to get an auth token
scope.systemLogin = function (username, password) {

View File

@@ -10,8 +10,10 @@ export default {
name: 'signOut',
route: '/logout',
controller: ['Authorization', '$state', function(Authorization, $state) {
Authorization.logout();
Authorization.logout().then( () =>{
$state.go('signIn');
});
}],
ncyBreadcrumb: {
skip: true