Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Google Brews with user auth if owner #3943

Merged
merged 3 commits into from
Dec 9, 2024
Merged

Get Google Brews with user auth if owner #3943

merged 3 commits into from
Dec 9, 2024

Conversation

calculuschild
Copy link
Member

@calculuschild calculuschild commented Dec 9, 2024

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 *

  • Google Brews can be created
  • can be updated
  • can be opened
  • can be shared to non-owners
  • can be assigned co-authors
  • co-authors can edit
  • appears in user page of author and co-author
  • when deleted by co-author, they are only removed as author
  • when deleted by owner, is transferred to Homebrewery and co-authors retain access
  • when deleted by last author, is deleted
  • can be deleted when permissions set to restricted

Some redundant logic and sprawling formatting
Fixes the case where a user can see a Google Brew under their account (`listBrew()` uses their personal auth) but can't actually delete it (`getBrew()`  only uses the serviceAccount). Occurs if a Google brew has lost its permissions somehow (set to "restricted", etc.) such that serviceAccount can no longer interact with it.
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3943 December 9, 2024 04:59 Inactive
@5e-Cleric 5e-Cleric added the 🔍 R0 - Needs first review 👀 PR ready but has not been reviewed label Dec 9, 2024
@calculuschild calculuschild merged commit 6136b78 into master Dec 9, 2024
2 checks passed
Copy link
Collaborator

@G-Ambatte G-Ambatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I also tested the Script Fix tool on a Google Brew in the deployment, which worked as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 R0 - Needs first review 👀 PR ready but has not been reviewed
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Brews removed from Google Drive cannot be deleted from "My Brews" page.
3 participants