diff --git a/ui/app/scripts/app.js b/ui/app/scripts/app.js index e2873c001d..6fde274b02 100644 --- a/ui/app/scripts/app.js +++ b/ui/app/scripts/app.js @@ -58,7 +58,7 @@ angular.module('thehive', [ } }, params: { - autoLogin: false + disableSsoAutoLogin: false }, title: 'Login' }) diff --git a/ui/app/scripts/controllers/AuthenticationCtrl.js b/ui/app/scripts/controllers/AuthenticationCtrl.js index 4ba859caff..a54abf1bc4 100644 --- a/ui/app/scripts/controllers/AuthenticationCtrl.js +++ b/ui/app/scripts/controllers/AuthenticationCtrl.js @@ -4,18 +4,21 @@ (function() { 'use strict'; angular.module('theHiveControllers') - .controller('AuthenticationCtrl', function($scope, $state, $location, $uibModalStack, $stateParams, AuthenticationSrv, NotificationSrv, UtilsSrv, UrlParser, appConfig) { + .controller('AuthenticationCtrl', function($scope, $state, $location, $uibModalStack, $stateParams, AuthenticationSrv, NotificationSrv, appConfig) { $scope.params = {}; + $scope.ssoLogingIn = false; $uibModalStack.dismissAll(); $scope.ssoLogin = function (code) { + $scope.ssoLogingIn = true; AuthenticationSrv.ssoLogin(code) .then(function(response) { var redirectLocation = response.headers().location; if(angular.isDefined(redirectLocation)) { window.location = redirectLocation; } else { + $location.search('code', null); $state.go('app.cases'); } }) @@ -25,6 +28,7 @@ } else { NotificationSrv.log(err.data.message, 'error'); } + $scope.ssoLogingIn = false; $location.url($location.path()); }); }; @@ -49,8 +53,8 @@ }); }; - var code = UtilsSrv.extractQueryParam('code', UrlParser('query', $location.absUrl())); - if(angular.isDefined(code) || $stateParams.autoLogin) { + var code = $location.search().code; + if(angular.isDefined(code) || (appConfig.config.ssoAutoLogin && !$stateParams.disableSsoAutoLogin)) { $scope.ssoLogin(code); } }); diff --git a/ui/app/scripts/controllers/RootCtrl.js b/ui/app/scripts/controllers/RootCtrl.js index acbd718b83..737f53231a 100644 --- a/ui/app/scripts/controllers/RootCtrl.js +++ b/ui/app/scripts/controllers/RootCtrl.js @@ -9,7 +9,7 @@ angular.module('theHiveControllers').controller('RootCtrl', $state.go('maintenance'); return; }else if(!currentUser || !currentUser.id) { - $state.go('login', {autoLogin: appConfig.config.ssoAutoLogin }); + $state.go('login'); return; } @@ -141,7 +141,7 @@ angular.module('theHiveControllers').controller('RootCtrl', $scope.logout = function() { AuthenticationSrv.logout(function() { - $state.go('login'); + $state.go('login', {disableSsoAutoLogin: true}); }, function(data, status) { NotificationSrv.error('RootCtrl', data, status); }); diff --git a/ui/app/scripts/services/UtilsSrv.js b/ui/app/scripts/services/UtilsSrv.js index 5a4fdb4288..6322ab2cb9 100644 --- a/ui/app/scripts/services/UtilsSrv.js +++ b/ui/app/scripts/services/UtilsSrv.js @@ -101,23 +101,6 @@ scope.value = scope.oldValue; scope.updatable.updating = false; }; - }, - - extractQueryParam: function(paramName, queryString) { - if (!queryString || !paramName) { - return; - } - - var param = $location.search()[paramName]; - - if (param) { - return param; - } else { - var parsedQuery = _.find(queryString.split('&'), function(str) { - return str.startsWith(paramName + '='); - }); - return parsedQuery ? parsedQuery.substr(paramName.length + 1) : undefined; - } } }; diff --git a/ui/app/views/login.html b/ui/app/views/login.html index 0c30c09a84..18bc6d7729 100644 --- a/ui/app/views/login.html +++ b/ui/app/views/login.html @@ -6,25 +6,25 @@
Sign in to start your session