From 5d56951fbce2db8d3aaceb4302f3f369b3a44dde Mon Sep 17 00:00:00 2001 From: Nabil Adouani Date: Wed, 24 Jun 2020 12:25:55 +0200 Subject: [PATCH] #1368 Define user's home page based on it's profile. --- frontend/app/scripts/app.js | 6 +---- .../scripts/services/api/AuthenticationSrv.js | 24 ++++++++++++++----- .../views/components/header.component.html | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/frontend/app/scripts/app.js b/frontend/app/scripts/app.js index f9c590e292..77bf9aed30 100644 --- a/frontend/app/scripts/app.js +++ b/frontend/app/scripts/app.js @@ -119,11 +119,7 @@ angular.module('thehive', [ .state('app.index', { url: 'index', onEnter: function($state, AuthenticationSrv) { - if(AuthenticationSrv.isSuperAdmin()) { - $state.go('app.administration.organisations', {}, {reload: true}); - } else { - $state.go('app.cases', {}, {reload: true}); - } + $state.go(AuthenticationSrv.getHomePage(), {}, {reload: true}); } }) .state('app.main', { diff --git a/frontend/app/scripts/services/api/AuthenticationSrv.js b/frontend/app/scripts/services/api/AuthenticationSrv.js index 8643165ddd..1ab6a927b0 100644 --- a/frontend/app/scripts/services/api/AuthenticationSrv.js +++ b/frontend/app/scripts/services/api/AuthenticationSrv.js @@ -50,12 +50,7 @@ var userData = response.data; self.currentUser = userData; - - if(self.isSuperAdmin()) { - self.currentUser.homeState = 'app.administration.organisations'; - } else { - self.currentUser.homeState = 'app.cases'; - } + self.currentUser.homeState = self.getHomePage(); UserSrv.updateCache(self.currentUser.login, self.currentUser); UtilsSrv.shallowClearAndCopy(self.currentUser, result); @@ -76,6 +71,23 @@ return user && user.organisation === 'admin'; }, + getHomePage: function() { + if(self.isSuperAdmin()) { + if(self.hasPermission('manageOrganisation')) { + return 'app.administration.organisations'; + } else if(self.hasPermission('manageProfile')) { + return 'app.administration.profiles'; + } else if (self.hasPermission('manageCustomField')) { + return 'app.administration.custom-fields'; + } else if(self.hasPermission('manageAnalyzerTemplate')) { + return 'app.administration.analyzer-templates'; + } else if(self.hasPermission('manageObservableTemplate')) { + return 'app.administration.observables'; + } + } else { + return 'app.cases'; + } + }, hasPermission: function(permissions) { var user = self.currentUser; diff --git a/frontend/app/views/components/header.component.html b/frontend/app/views/components/header.component.html index 7ffeb46a8b..391fb02dfb 100644 --- a/frontend/app/views/components/header.component.html +++ b/frontend/app/views/components/header.component.html @@ -79,7 +79,7 @@