Refactor to remove author.email from API #5159
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Essentially, this PR gets rid of a TODO in frontend.js, but ends up requiring us to ensure we pass the
context
object through to thetoJSON
object, so that it can check whether or not a field should be included. This is potentially useful for doing other post-fetch checks based on permissions in future, but there may be a better way with bookshelf plugins.Doing this at the toJSON level ensures that the email is correctly removed no matter how the user object is fetched (i.e. if it's from the post API or the user API).
This also fixes a bug whereby the author.email is incorrectly available when on an author page.
Finally this means the email will also be correctly removed when using the get helper.
refs #2330
options
to all toJSON calls on posts, tags, and users