30 lines
687 B
JavaScript
30 lines
687 B
JavaScript
module.exports = plugin => {
|
|||
|
|
const sanitizeOutput = (user) => {
|
||
|
|
const {password, resetPasswordToken, confirmationToken, ...sanitizedUser} = user
|
||
|
|
return sanitizedUser;
|
||
|
|
};
|
||
|
|
|
||
|
|
plugin.controllers.user.me = async (ctx) => {
|
||
|
|
if (!ctx.state.user) {
|
||
|
|
return ctx.unauthorized();
|
||
|
|
}
|
||
|
|
|
||
|
|
const user = await strapi.entityService.findOne('plugin::users-permissions.user', ctx.state.user.id, {populate: {
|
||
|
|
paroles: {
|
||
|
|
filters: {
|
||
|
|
publishedAt: {
|
||
|
|
$eq: null
|
||
|
|
}
|
||
|
|
},
|
||
|
|
populate: {
|
||
|
|
artistes: true,
|
||
|
|
traductions: true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}})
|
||
|
|
|
||
|
|
ctx.body = sanitizeOutput(user)
|
||
|
|
}
|
||
|
|
return plugin
|
||
|
|
}
|