diff --git a/src/api/parole/content-types/parole/lifecycles.js b/src/api/parole/content-types/parole/lifecycles.js index ef195b3..704e372 100644 --- a/src/api/parole/content-types/parole/lifecycles.js +++ b/src/api/parole/content-types/parole/lifecycles.js @@ -47,7 +47,14 @@ const jwennUserEpiId = async userId => { return null } - const user = await strapi.db.query('plugin::users-permissions.user').findOne({id: userId}) + const user = await strapi.db.query('plugin::users-permissions.user').findOne({ + where: {id: userId} + }) + + if (!user) { + throw new ValidationError('Utilisateur introuvable.') + } + return user } @@ -179,7 +186,7 @@ module.exports = { }, afterCreate: async event => { const {data} = event.params - const user = await jwennUserEpiId(data.user) + const user = await jwennUserEpiId(data?.user?.id) const userAdmin = await jwennUserAdminEpiId(data?.createdBy) const superAdmin = await jwennSuperAdminEpiId(data?.createdBy) const traductionsId = data.traductions.id