Fix requested user error & throw exception
This commit is contained in:
@@ -47,7 +47,14 @@ const jwennUserEpiId = async userId => {
|
|||||||
return null
|
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
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +186,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
afterCreate: async event => {
|
afterCreate: async event => {
|
||||||
const {data} = event.params
|
const {data} = event.params
|
||||||
const user = await jwennUserEpiId(data.user)
|
const user = await jwennUserEpiId(data?.user?.id)
|
||||||
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
|
const userAdmin = await jwennUserAdminEpiId(data?.createdBy)
|
||||||
const superAdmin = await jwennSuperAdminEpiId(data?.createdBy)
|
const superAdmin = await jwennSuperAdminEpiId(data?.createdBy)
|
||||||
const traductionsId = data.traductions.id
|
const traductionsId = data.traductions.id
|
||||||
|
|||||||
Reference in New Issue
Block a user