Get Google Brews with user auth if owner #3943
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.
Description
Supercedes #2955
Alters
getBrew()
to use the current user Google Auth instead of the ServiceAccount if current user is the owner. This fixes the issue in #2955 wherein the Homebrewery has lost permissions to the Google Brew (set to "restricted", etc.). This would cause the brew to be listed under the user account (brews are fetched using User Auth), but unable to delete it (brews are deleted using ServiceAccount).The difference here from #2955 is a logic to only apply User Auth if the current user is the owner (first author, or no stub => no authors). This avoids the conflict where a co-author would be stuck unable to interact with the brew because their own user auth cannot see the document. This logic is handled internal to
getBrew()
, so the auth does not need to be passed in externally.This PR also includes a handful of refactorings of
getBrew()
made along the way to find where the appropriate logic should be applied.Related Issues or Discussions
Reviewer Checklist
*Reviewers, refer to this list when testing features, or suggest new items *