Skip to content

Commit

Permalink
#161 Handle 520 error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Apr 19, 2017
1 parent e61253d commit f67e758
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions ui/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ angular.module('thehive', ['ngAnimate', 'ngMessages', 'ngSanitize', 'ui.bootstra
templateUrl: 'views/app.html',
controller: 'RootCtrl',
resolve: {
currentUser: function($q, AuthenticationSrv) {
currentUser: function($q, $state, AuthenticationSrv) {
var deferred = $q.defer();

AuthenticationSrv.current(function(userData) {
return deferred.resolve(userData);
}, function( /*err, status*/ ) {
return deferred.resolve(null);
}, function(err, status) {
if (status === 520) {
return deferred.resolve('maintenance')
} else {
return deferred.resolve(status);
}

});

return deferred.promise;
Expand Down
5 changes: 4 additions & 1 deletion ui/app/scripts/controllers/RootCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ angular.module('theHiveControllers').controller('RootCtrl',
function($scope, $rootScope, $uibModal, $location, $state, $base64, AuthenticationSrv, AlertingSrv, StreamSrv, StreamStatSrv, TemplateSrv, MetricsCacheSrv, NotificationSrv, AppLayoutSrv, currentUser, appConfig) {
'use strict';

if(!currentUser || !currentUser.id) {
if(currentUser === 'maintenance') {
$state.go('maintenance');
return;
}else if(!currentUser || !currentUser.id) {
$state.go('login');
return;
}
Expand Down

0 comments on commit f67e758

Please sign in to comment.