Comments (2)
@Ethanpolley You can override the user controller in the extensions folder
- Create a folder named
controllers
inside<your_strapi_project>/extensions/user-permissions
- Inside the newly created controllers folder create a new js file called
User.js
- Add the following code inside
const _ = require("lodash");
const { sanitizeEntity } = require("strapi-utils");
const sanitizeUser = user =>
sanitizeEntity(user, {
model: strapi.query("user", "users-permissions").model
});
const formatError = error => [
{ messages: [{ id: error.id, message: error.message, field: error.field }] }
];
module.exports = {
/**
* Retrieve user records.
* @return {Object|Array}
*/
async find(ctx, next, { populate } = {}) {
let users;
ctx.set(
"Content-Range",
await strapi.query("user", "users-permissions").count({})
);
if (_.has(ctx.query, "_q")) {
// use core strapi query to search for users
users = await strapi
.query("user", "users-permissions")
.search(ctx.query, populate);
} else {
users = await strapi.plugins["users-permissions"].services.user.fetchAll(
ctx.query,
populate
);
}
const data = users.map(sanitizeUser);
ctx.send(data);
}
};
- Profit
from ra-strapi-rest.
@Ethanpolley If the solution given above does not resolve your problem you are welcome to re-open this issue.
Thanks!
from ra-strapi-rest.
Related Issues (20)
- updated/alt auth example HOT 2
- Get Entire File Url HOT 6
- TypeError: _dataProvider_server_rest__WEBPACK_IMPORTED_MODULE_3__.strapiDataProvider.getOne is not a function HOT 5
- Suggestion: Replace Content-Range HOT 1
- ImageInput causes CastError: Cast to ObjectId failed for value "[]" at path "avatar" HOT 3
- Unable to show data in ArrayField HOT 2
- ReferenceField not displaying data in List view HOT 1
- Has and belongs to many relation HOT 1
- Handle Strapi validation errors HOT 4
- Handle Strapi Components Show And Update HOT 8
- The dataProvider threw an error. It should return a rejected Promise instead.
- Add example for Relations to the Readme HOT 4
- N/A
- ImageInput causes CastError: Cast to ObjectId failed for value "[]" at path "avatar" HOT 1
- Strapi v4 is released HOT 4
- Single-Type Support HOT 1
- Fails with current version of strapi and react admin HOT 5
- No edit / or show buttons?
- Error for creating ressource HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ra-strapi-rest.