fix(mutations/execute-flow): correct permission check
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
import testRun from '../../services/test-run';
|
import testRun from '../../services/test-run';
|
||||||
|
import Step from '../../models/step';
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
input: {
|
input: {
|
||||||
@@ -12,12 +13,16 @@ const executeFlow = async (
|
|||||||
params: Params,
|
params: Params,
|
||||||
context: Context
|
context: Context
|
||||||
) => {
|
) => {
|
||||||
context.currentUser.can('update', 'Flow');
|
const conditions = context.currentUser.can('update', 'Flow');
|
||||||
|
const isCreator = conditions.isCreator;
|
||||||
|
const allSteps = Step.query();
|
||||||
|
const userSteps = context.currentUser.$relatedQuery('steps');
|
||||||
|
const baseQuery = isCreator ? userSteps : allSteps;
|
||||||
|
|
||||||
const { stepId } = params.input;
|
const { stepId } = params.input;
|
||||||
|
|
||||||
const untilStep = await context.currentUser
|
const untilStep = await baseQuery
|
||||||
.$relatedQuery('steps')
|
.clone()
|
||||||
.findById(stepId)
|
.findById(stepId)
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user