Open zgldh opened 2 months ago
@zgldh Thanks for the tip.
I am curious, is the @CrudAuth decorator not working for you ? Something like :
@CrudAuth({
property: 'user',
filter: (user: CurrentUser) => {
return { 'User.id': { $eq: user.id } };
},
})
@Controller(CONTROLLER_PATH)
export class SomeController {
}
This assumes that your currently logged in user is available in the user
property of the request.
Hi @zaro , that's a good solution.
For my use case, we may not need to perform a filter for all actions of a controller. Thus why I did it like that. But thanks anyway.
Sometimes your system need to add filter conditions after the HTTP request parsed.
For example you would like to filter records by current login user ID.
You would be like to do it as following: