fix: corriger les mauvais identifiants utilisés (id vs documentId)

This commit is contained in:
2026-07-04 09:43:28 +04:00
parent 8b17882d6b
commit ddb6d3f2f0
4 changed files with 141 additions and 8 deletions
@@ -21,8 +21,8 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
throw new UnauthorizedError(ctx, err, 'Opération non autorisée')
}
}
const user = await strapi.documents('plugin::users-permissions.user').findOne({
documentId: data.user.documentId
const user = await strapi.db.query('plugin::users-permissions.user').findOne({
where: {id: data.user.id}
})
if (!user) {
@@ -35,9 +35,8 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
data.user = user.id
const parole = await strapi.documents('api::parole.parole').findOne({
documentId: user.documentId,
fields: ['id']
const parole = await strapi.db.query('api::parole.parole').findOne({
where: {id: data.parole}
})
if (!parole) {
@@ -51,7 +50,7 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
})
await strapi.documents('api::parole.parole').update({
documentId: user.documentId,
documentId: parole.documentId,
data: {
commentaires: [newCommentaire.id]