Skip to content

Commit

Permalink
fix permission check
Browse files Browse the repository at this point in the history
widgets and views
  • Loading branch information
单萌萌 committed May 23, 2019
1 parent be40398 commit e24373f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ userfiles/
.vscode
*yarn.lock
bin/upgrade.go
davinci-ui/
bin/upgrade/
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ public List<ViewBaseInfo> getViews(Long projectId, User user) throws NotFoundExc

if (null != views) {
ProjectPermission projectPermission = projectService.getProjectPermission(projectDetail, user);
if (projectPermission.getViewPermission() == UserPermissionEnum.HIDDEN.getPermission()) {
if (projectPermission.getVizPermission() == UserPermissionEnum.HIDDEN.getPermission() &&
projectPermission.getWidgetPermission() == UserPermissionEnum.HIDDEN.getPermission() &&
projectPermission.getViewPermission() == UserPermissionEnum.HIDDEN.getPermission()) {
return null;
}
}
Expand All @@ -159,8 +161,10 @@ public ViewWithSourceBaseInfo getView(Long id, User user) throws NotFoundExcepti

ProjectDetail projectDetail = projectService.getProjectDetail(view.getProjectId(), user, false);
ProjectPermission projectPermission = projectService.getProjectPermission(projectDetail, user);
if (projectPermission.getViewPermission() == UserPermissionEnum.HIDDEN.getPermission()) {
throw new NotFoundException("Insufficient permissions");
if (projectPermission.getVizPermission() == UserPermissionEnum.HIDDEN.getPermission() &&
projectPermission.getWidgetPermission() == UserPermissionEnum.HIDDEN.getPermission() &&
projectPermission.getViewPermission() == UserPermissionEnum.HIDDEN.getPermission()) {
throw new UnAuthorizedExecption("Insufficient permissions");
}

List<RelRoleView> relRoleViews = relRoleViewMapper.getByView(view.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public List<Widget> getWidgets(Long projectId, User user) throws NotFoundExcepti

if (null != widgets) {
ProjectPermission projectPermission = projectService.getProjectPermission(projectDetail, user);
if (projectPermission.getWidgetPermission() == UserPermissionEnum.HIDDEN.getPermission()) {
if (projectPermission.getVizPermission() == UserPermissionEnum.HIDDEN.getPermission() &&
projectPermission.getWidgetPermission() == UserPermissionEnum.HIDDEN.getPermission()) {
return null;
}
}
Expand Down

0 comments on commit e24373f

Please sign in to comment.