chore: activer ESLint sur le backend
Installe eslint, ajoute le script lint, modernise le parser (retrait de babel-eslint obsolète) et applique l'autofix (points-virgules manquants sur l'ensemble du code, conformément à la règle "semi" déjà présente dans .eslintrc mais jamais appliquée faute d'ESLint installé et d'un script pour l'exécuter).
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const { UnauthorizedError } = require('@strapi/utils').errors
|
||||
const { UnauthorizedError } = require('@strapi/utils').errors;
|
||||
|
||||
module.exports = async (policyContext, config, {strapi}) => {
|
||||
const {request} = policyContext
|
||||
const {request} = policyContext;
|
||||
|
||||
if (!request?.header?.authorization) {
|
||||
throw new UnauthorizedError('Opération non autorisée')
|
||||
throw new UnauthorizedError('Opération non autorisée');
|
||||
}
|
||||
|
||||
try {
|
||||
const {id} = await strapi.plugins['users-permissions'].services.jwt.getToken(policyContext)
|
||||
const {id} = await strapi.plugins['users-permissions'].services.jwt.getToken(policyContext);
|
||||
|
||||
if (id !== request.body?.data?.user?.id) {
|
||||
throw new UnauthorizedError('Opération non autorisée')
|
||||
throw new UnauthorizedError('Opération non autorisée');
|
||||
}
|
||||
} catch (err) {
|
||||
throw new UnauthorizedError('Opération non autorisée')
|
||||
throw new UnauthorizedError('Opération non autorisée');
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user