Fix requested user error & throw exception

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-10-24 00:08:42 +04:00
parent b9b98f20f8
commit 04b2a63387
@@ -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