This commit is contained in:
Aurelsicoko 2018-05-24 17:20:32 +02:00
parent 0a9fff5a30
commit c111aaba13
10 changed files with 15 additions and 11 deletions

View File

@ -51,4 +51,4 @@
"npm": ">= 5.0.0" "npm": ">= 5.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -117,4 +117,4 @@
"webpack-hot-middleware": "^2.18.2", "webpack-hot-middleware": "^2.18.2",
"whatwg-fetch": "^2.0.3" "whatwg-fetch": "^2.0.3"
} }
} }

View File

@ -46,4 +46,4 @@
"npm": ">= 5.0.0" "npm": ">= 5.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -50,4 +50,4 @@
"npm": ">= 5.0.0" "npm": ">= 5.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -328,7 +328,7 @@ module.exports = {
return async (obj, options, context) => { return async (obj, options, context) => {
// Hack to be able to handle permissions for each query. // Hack to be able to handle permissions for each query.
const ctx = Object.assign(context, { const ctx = Object.assign(_.clone(context), {
request: Object.assign(_.clone(context.request), { request: Object.assign(_.clone(context.request), {
graphql: null graphql: null
}) })
@ -362,6 +362,7 @@ module.exports = {
return values && values.toJSON ? values.toJSON() : values; return values && values.toJSON ? values.toJSON() : values;
} }
return resolver.call(null, obj, options, context); return resolver.call(null, obj, options, context);
} }
@ -560,7 +561,7 @@ module.exports = {
switch (association.nature) { switch (association.nature) {
case 'manyToMany': { case 'manyToMany': {
const arrayOfIds = obj[association.alias].map(related => { const arrayOfIds = (obj[association.alias] || []).map(related => {
return related[ref.primaryKey] || related; return related[ref.primaryKey] || related;
}); });

View File

@ -48,4 +48,4 @@
"npm": ">= 5.0.0" "npm": ">= 5.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -47,4 +47,4 @@
"npm": ">= 3.0.0" "npm": ">= 3.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -39,9 +39,11 @@ module.exports = async (ctx, next) => {
}, []); }, []);
if (!permission) { if (!permission) {
ctx.forbidden(); if (ctx.request.graphql === null) {
return ctx.request.graphql = strapi.errors.forbidden();
}
return ctx.request.graphql = ctx.body; ctx.forbidden();
} }
// Execute the policies. // Execute the policies.

View File

@ -54,4 +54,4 @@
"npm": ">= 5.0.0" "npm": ">= 5.0.0"
}, },
"license": "MIT" "license": "MIT"
} }

View File

@ -19,6 +19,7 @@ module.exports = strapi => {
this.delegator = delegate(strapi.app.context, 'response'); this.delegator = delegate(strapi.app.context, 'response');
this.createResponses(); this.createResponses();
strapi.errors = Boom;
strapi.app.use(async (ctx, next) => { strapi.app.use(async (ctx, next) => {
try { try {
// App logic. // App logic.