#6 -- Check permissions to the variable
Some checks failed
CI fuzzy controller / container-test-job (push) Has been cancelled
Some checks failed
CI fuzzy controller / container-test-job (push) Has been cancelled
This commit is contained in:
parent
d5a6074e1f
commit
0093416e6c
@ -14,15 +14,18 @@ public class VariableService {
|
||||
private final VariableRepository variableRepository;
|
||||
private final ProjectService projectService;
|
||||
|
||||
public VariableService(VariableRepository variableRepository, ProjectService projectService) {
|
||||
public VariableService(VariableRepository variableRepository,
|
||||
ProjectService projectService) {
|
||||
this.variableRepository = variableRepository;
|
||||
this.projectService = projectService;
|
||||
}
|
||||
|
||||
public Variable getById(Integer id) {
|
||||
return variableRepository
|
||||
Variable variable = variableRepository
|
||||
.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("Variable not found by id"));
|
||||
checkIsCurrentUserVariableWithThrow(variable);
|
||||
return variable;
|
||||
}
|
||||
|
||||
public Variable save(VariableForm variableForm) {
|
||||
@ -65,4 +68,8 @@ public class VariableService {
|
||||
public List<Variable> getAllByProject(Integer projectId) {
|
||||
return variableRepository.getByProject(projectService.getById(projectId));
|
||||
}
|
||||
|
||||
public void checkIsCurrentUserVariableWithThrow(Variable variable) {
|
||||
projectService.checkIsCurrentUserProjectWithThrow(variable.getProject());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user