Closed techandmedia closed 2 years ago
Hi @techandmedia 👋 thanks for raising this issue. Just a few things:
Do you mean you are creating these records while logged in as a Cognito User, logging out and still able to query the records?
Are you able to query and access these records as a guest or different user in another browser?
Hi @techandmedia 👋 thanks for raising this issue. Just a few things:
- Do you mean you are creating these records while logged in as a Cognito User, logging out and still able to query the records?
- Are you able to query and access these records as a guest or different user in another browser/private window?
What happens? When I logged out I also cleared Datastore like so
const { user, signOut } = useAuthenticator(context => [context.user]);
function logout() {
signOut(); //
DataStore.clear();
}
Here you can test this https://github.com/techandmedia/next-amplify-react18/tree/testing-blog
And here is the current situation which scenario as follow
I am not sure if this is correct, like needing to refresh browser to see the current data, shouldn't it updated in real time? Otherwise the user will think they get false data
Update 1 The strange behaviour also happens in browser B, private blog wont show up until the user add a private blog or the user refresh the browser Browser A; Chrome Browser B: Firefox
Update 2
User B in browser B add a public blog, user B see their public blogs updated, but not in browser A, either logged in or not
Moving some codes in useEffect, now works fine
Update 3 Error in private mode in Firefox [ERROR] 16:37.260 DataStore - IndexedDB not supported in this browser's private mode
Strange behaviour in Chrome, it doesn't matter how many times I logged in, logout, the number of data for public blog is incorrect, still showing old data (8 contents), while in Firefox, always correct
Moving some codes in useEffect, now works fine
Hey @techandmedia , sorry, I forgot DataStore won't work in a private window where IndexedDB API is not available. Just using another browser and logging in as another user should suffice. The goal was to simulate and test whether one user on one "device" (browser A) could query another user's data on another "device" (browser B), which doesn't seem to be the case.
DataStore only interacts with the local store (indexedDB in browser) so any data a user creates on a device will remain stored on the device and accessible to DataStore unless cleared. We recommend using DataStore.clear()
on logout and/or when a different user logs in to remove any data you don't want a different user on the same device to access.
So, need to keep in mind that data stored on the device, as the main purpose of DataStore is offline capability, can be accessed or viewed in local storage by anyone with access to the device. Consider this when deciding what data you actually want to be stored locally. For data you'd rather keep only on the server you can use API.graphql
instead as the auth rules will always be respected when trying to access data from the server.
This being said, it sounds like the current issue you're facing is that the observeQuery
subscription (PrivateBlog model?) is not returning new data until the user creates another record or the page is refreshed. Is that correct?
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.
Thank you!
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server amplify-help
forum.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
DataStore
Amplify Categories
Not applicable
Environment information
Describe the bug
An unauthorized / guest user able to access model with rules "owner"
Expected behavior
Only an owner of the record able to access the data
Reproduction steps
Setup Amplify project Add multiple models as below code snippet Then fetch the data using Datastore
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response