In case a page is opened in edit mode, it should open with permission of MANAGE_PAGE. In case the user is a viewer, the page must not open.

This commit is contained in:
Trisha Anand 2020-06-17 17:34:26 +05:30
parent e9086c15b5
commit e5282dac11
2 changed files with 10 additions and 1 deletions

View File

@ -56,6 +56,14 @@ public class PageController extends BaseController<PageService, Page, String> {
.map(resources -> new ResponseDTO<>(HttpStatus.OK.value(), resources, null));
}
@Override
@GetMapping("/{pageId}")
public Mono<ResponseDTO<Page>> getById(@PathVariable String pageId) {
return applicationPageService.getPage(pageId, false)
.map(page -> new ResponseDTO<>(HttpStatus.OK.value(), page, null));
}
@GetMapping("/{pageId}/view")
public Mono<ResponseDTO<Page>> getPageView(@PathVariable String pageId) {
return applicationPageService.getPage(pageId, true)

View File

@ -118,7 +118,8 @@ public class ApplicationPageServiceImpl implements ApplicationPageService {
}
public Mono<Page> getPage(String pageId, Boolean viewMode) {
return pageService.findById(pageId, READ_PAGES)
AclPermission permission = viewMode ? READ_PAGES : MANAGE_PAGES;
return pageService.findById(pageId, permission)
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.PAGE_ID)))
.map(page -> {
List<Layout> layoutList = page.getLayouts();