fix: stopper l'exécution après un refus d'autorisation dans parole.create

This commit is contained in:
2026-07-04 09:36:17 +04:00
parent 796b4379fd
commit f592d4ded7
2 changed files with 96 additions and 5 deletions
+5 -5
View File
@@ -78,10 +78,10 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
].services.jwt.getToken(ctx)
if (id !== data.user.id) {
ctx.unauthorized('Opération non autorisée')
return ctx.unauthorized('Opération non autorisée')
}
} catch (err) {
ctx.unauthorized(ctx, err, 'Opération non autorisée')
return ctx.unauthorized('Opération non autorisée')
}
}
@@ -90,11 +90,11 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
})
if (!user) {
ctx.notFound('Utilisateur introuvable.')
return ctx.notFound('Utilisateur introuvable.')
}
if (user.id !== data.user.id || user.username !== data.user.username || user.email !== data.user.email) {
ctx.badRequest('Informations non valides.')
return ctx.badRequest('Informations non valides.')
}
const artiste = await strapi.documents('api::artiste.artiste').findOne({
@@ -102,7 +102,7 @@ module.exports = createCoreController('api::parole.parole', ({strapi}) => ({
})
if (!artiste) {
ctx.notFound('Artiste introuvable.')
return ctx.notFound('Artiste introuvable.')
}
const currentUserParole = await strapi.documents('api::parole.parole').findMany({