Wrapping timer init in promise

to ensure that timer is started before initializing websockets. This was leading to instances where the websocket thought that the session
hadn't been started yet. Also fixed an issue where the session wasn't tearing down the $interval when AUTH_TOKEN_PER_USER had been exceeded.
This commit is contained in:
Jared Tabor
2015-10-27 13:51:54 -07:00
parent 80eeda1c8c
commit 6c8597cf95
5 changed files with 29 additions and 16 deletions

View File

@@ -165,9 +165,12 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
Authorization.getUser()
.success(function (data) {
Authorization.setUserInfo(data);
$rootScope.sessionTimer = Timer.init();
$rootScope.user_is_superuser = data.results[0].is_superuser;
scope.$emit('AuthorizationGetLicense');
Timer.init().then(function(timer){
$rootScope.sessionTimer = timer;
$rootScope.$emit('OpenSocket');
$rootScope.user_is_superuser = data.results[0].is_superuser;
scope.$emit('AuthorizationGetLicense');
});
})
.error(function (data, status) {
Authorization.logout();