From f7379bf34d230f654007a3acb172723afd56a125 Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Tue, 23 Jun 2020 15:01:05 +0200 Subject: [PATCH] #1402 Fix 401 error handling in router --- frontend/app/scripts/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/app/scripts/app.js b/frontend/app/scripts/app.js index 2f6acf7360..f9c590e292 100644 --- a/frontend/app/scripts/app.js +++ b/frontend/app/scripts/app.js @@ -617,5 +617,12 @@ angular.module('thehive', [ $rootScope.title = toState.title; } }); + + $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error){ + if(error && error.status && error.status === 401) { + event.preventDefault(); + $state.go('login'); + } + }); }) .constant('UrlParser', url);