mirror of
https://github.com/strapi/strapi.git
synced 2025-07-13 12:02:10 +00:00
Fixes #1247
This commit is contained in:
parent
0a9fff5a30
commit
c111aaba13
@ -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;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
@ -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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user