-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
issue: enhancementIssue suggesting an enhancement to an existing featureIssue suggesting an enhancement to an existing featuresource: core:strapiSource is core/strapi packageSource is core/strapi package
Description
Bug report
Describe the bug
Filters in findOne controller doesn't work.
Steps to reproduce the behavior
- Create a controller like this:
async findOne(ctx) {
// Filter by the current user as the author
ctx.query = {
...ctx.query,
filters: {
author: {
id: ctx.state.user.id
}
},
};
const response = await super.findOne(ctx);
return response;
},- Run the REST
GET /content-type/:id - It shows the entry, even if the user is not the author
Expected behavior
The custom filter working
System
- Node.js version: v14
- NPM version: v8
- Strapi version: v4.0.4
- Database: SQLite
- Operating system: macOS
Additional context
Debugging a bit...
After this:
strapi/packages/core/strapi/lib/core-api/service/collection-type.js
Lines 54 to 56 in 31259db
| findOne(entityId, params = {}) { | |
| return strapi.entityService.findOne(uid, entityId, this.getFetchParams(params)); | |
| }, |
I see that this line removes the custom params:
| const query = transformParamsToQuery(uid, pickSelectionParams(wrappedParams)); |
Metadata
Metadata
Assignees
Labels
issue: enhancementIssue suggesting an enhancement to an existing featureIssue suggesting an enhancement to an existing featuresource: core:strapiSource is core/strapi packageSource is core/strapi package
Type
Projects
Status
Archive
Status
Closed