fix: stopper l'exécution après un refus d'autorisation dans parole.create
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user