I am writing an API that returns all Users that fit a certain criteria and their associated models in JSON format.
My question is–how do I make it automatically not return the hashed password field when returning the user data to the client who is getting my JSON data? This seems like it should be a standard problem, but without using contain/fields, can I make it so that the default behavior is it does not return the hashed password whenever I do a simple find?
Thanks!
You can use the models
afterFind()to remove the password from the result set like so: