Skip to content

Commit

Permalink
#1368 Define user's home page based on it's profile.
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 24, 2020
1 parent f7379bf commit 5d56951
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
6 changes: 1 addition & 5 deletions frontend/app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
24 changes: 18 additions & 6 deletions frontend/app/scripts/services/api/AuthenticationSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/components/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<b class="caret"></b>
</a>
<ul class="dropdown-menu" uib-dropdown-menu>
<li>
<li if-permission="manageOrganisation">
<a ui-sref="app.administration.organisations">
<i class="fa fa-building-o"></i>
<span class="hpad5">Organisations</span>
Expand Down

0 comments on commit 5d56951

Please sign in to comment.