Skip to content
Snippets Groups Projects
Commit 8882675a authored by moon's avatar moon
Browse files

Included 'role' in findOne method

parent bd9a7ccc
No related branches found
No related tags found
No related merge requests found
const utils = require('@strapi/utils');
const { getService } = require("@strapi/plugin-users-permissions/server/utils");
const { sanitize } = utils;
const sanitizeOutput = (user, ctx) => {
const schema = strapi.getModel('plugin::users-permissions.user');
const { auth } = ctx.state;
return sanitize.contentAPI.output(user, schema, { auth });
};
module.exports = (plugin) => {
plugin.controllers.user.findOne = async (ctx) => {
const { id } = ctx.params;
let data = await getService('user').fetch({ id }, ['role']);
if (data) {
data = await sanitizeOutput(data, ctx);
}
ctx.body = data;
};
return plugin;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment