Merge pull request #1412 from automatisch/aut-311
fix: let permitted users create step in not-owned flows
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
|
import Flow from '../../models/flow';
|
||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
@@ -22,7 +23,10 @@ const createStep = async (
|
|||||||
params: Params,
|
params: Params,
|
||||||
context: Context
|
context: Context
|
||||||
) => {
|
) => {
|
||||||
context.currentUser.can('update', 'Flow');
|
const conditions = context.currentUser.can('update', 'Flow');
|
||||||
|
const userFlows = context.currentUser.$relatedQuery('flows');
|
||||||
|
const allFlows = Flow.query();
|
||||||
|
const flowsQuery = conditions.isCreator ? userFlows : allFlows;
|
||||||
|
|
||||||
const { input } = params;
|
const { input } = params;
|
||||||
|
|
||||||
@@ -34,8 +38,7 @@ const createStep = async (
|
|||||||
await App.findOneByKey(input.appKey);
|
await App.findOneByKey(input.appKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
const flow = await context.currentUser
|
const flow = await flowsQuery
|
||||||
.$relatedQuery('flows')
|
|
||||||
.findOne({
|
.findOne({
|
||||||
id: input.flow.id,
|
id: input.flow.id,
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user