Rank 2: Process
I'm making a React web-app where users can log in, add a document, but I want them to only be able to view documents they have created. So far I'm just running it locally. Here's how they're being saved:
try {
return databases.createDocument(
DATABASE_ID,
COLLECTION,
ID.unique(),
newRecipe,
[
Permission.delete(Role.user(currUser.$id)),
Permission.update(Role.user(currUser.$id)),
Permission.read(Role.user(currUser.$id))
]);
}
I'm using account.get() once a user is logged in and saving the user in context, that's how I access the ID.
I look at the new document and it shows the correct permissions based on the ID.
I have document security enabled.
I'm retrieving the documents with:
(await databases.listDocuments([DATABASE_ID], [COLLECTION_ID])).documents
But it returns all of the documents, not just the one the current user should be able to view. Should I be filtering the documents somehow? Should I add an attribute that's populated with the user's ID and filter by that? Is it unsecure to be having the user's information on the client side in context...?
I've looked at the appwrite example (https://github.com/appwrite/demo-todo-with-react/tree/main) but can't figure out where I'm going wrong.
I'm only front-end (self-taught) but have made some Jamstack web-apps; I keep trying to turn one into something where users can securely log into and access their data, but have yet to succeed. Don't know if I'm overthinking things or just completely wrong in my attempts.