6-project-permissions #19
@ -28,7 +28,7 @@ public class ProjectService {
|
|||||||
Project project = projectRepository
|
Project project = projectRepository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
.orElseThrow(() -> new RuntimeException("Project not found by id"));
|
.orElseThrow(() -> new RuntimeException("Project not found by id"));
|
||||||
checkUserProjectWithThrow(project, userService.getCurrentUser());
|
checkIsCurrentUserProjectWithThrow(project);
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +52,8 @@ public class ProjectService {
|
|||||||
projectRepository.deleteById(projectForm.getId());
|
projectRepository.deleteById(projectForm.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkUserProjectWithThrow(Project project, User currentUser) {
|
public void checkIsCurrentUserProjectWithThrow(Project project) {
|
||||||
if (!isUserProject(project, currentUser)) {
|
if (!isUserProject(project, userService.getCurrentUser())) {
|
||||||
throw new RuntimeException("User can not get access to project");
|
throw new RuntimeException("User can not get access to project");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user