-
Notifications
You must be signed in to change notification settings - Fork 329
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
Add Google file link to UserPage BrewItem #2969
Add Google file link to UserPage BrewItem #2969
Conversation
The second part of this PR adds a small icon for brews stored on the local MongoDB database, to differentiate them from the brews stored on Google Drive. |
|
||
return <span> | ||
<img className='googleDriveIcon' src={googleDriveIcon} alt='googleDriveIcon' /> | ||
return <span title='Google Drive Storage'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the Title should be “Saved on [User]’s Google Drive”?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done with the owners
field from the Google API. Unfortunately it would only work for brews owned by the current logged-in user where we call listGoogleBrews()
Maybe in that case we could display Another User's Google Drive Storage
to at least make clear that you aren't logged in to the owning account.
Does webViewLink work if the user looking at the Users Page is not the owner of that User Page? For example, if anyone but me looks at https://homebrewery.naturalcrit.com/user/erics, will the Google Drive link for the one brew I have there on gdrive work for them? |
A quick perusal of the code shows that when When |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so as pointed out, this only works if you are logged in to the owner's google drive account. If not, the webViewLink is undefined since we are just reading from the stub without actually performing listGoogleBrews()
; Often the reason a user can't find the file is because they aren't logged in to the right account. So what should we display to the user in that case?
Edit: It looks like the webViewLink can by derived by just using the Google ID which we have, so we could apply this to all brews on the page, even those from a Stub:
- googleID : 1eynUmZHfmTc6fDQupTvxgxlhxGyrwoPw
- webViewLink : https://drive.google.com/file/d/1eynUmZHfmTc6fDQupTvxgxlhxGyrwoPw/view?usp=drivesdk
Then the link would work for everyone, even if logged out (or in the wrong account). Displaying whether that file exists is another question, but visiting the link would at least show an error from google in that case:
Given that every Google brew needs to be set as 'Anyone with the link can Edit' in order for things to work, exposing the link is problematic, from a data security perspective. |
Hmm, good point. I was thinking only about users who are looking at their own accounts, meaning they are already also authors and should have edit privileges anyway, but this would expose the link to any random visitor to your user page too. What about showing the link only if you are looking at your own brews page? I think there may still be some benefit to being able to link to files you are an author on, even if you don't own it. For the same reasons as before (user has multiple Google accounts and has "lost" the file, etc.)? |
That seems reasonable, I think - if you're an author, you can edit the brew, so being able to see the source file poses a minimal additional security exposure. The only negative case I can think of immediately is a removed author might be able to retain access via the Google Drive link in their history. The upside to that is that Google Drive version history allows for the relatively painless restoration of the file in the event that a malicious ex-author vandalizes a file. |
Also, the presence of a |
Ok, I think this is good enough as is. I'll go ahead and merge. Thanks @G-Ambatte ! |
This PR follows up on a side issue raised in #2954.
This PR adds a link to the file on Google Drive via the Drive Icon on the User Page. In the event that a user cannot find their brew document but it does still exist in their Drive somewhere, they can use this link to locate the file.