Back

[SOLVED] Document Permissions

  • 0
  • Web
taavisaft
25 May, 2023, 08:48

I have collection level permissions to create documents for other users. But i can't add document level permissions for them to see my created document. I get "AppwriteException: Permissions must be one of: ...." Why is that so? Do i have to use Server SDK to solve that?

TL;DR
User is seeking help with document permissions in an Appwrite application. They want to create a document for another user and give that user read and edit access on the document level. They have tried using collection-level permissions but are getting an error. They are wondering if they need to use the server-side SDK to solve the issue. Solution: The user can create a function in Appwrite that sets the document permissions as needed. They can execute this function from the client-side by providing the document ID as payload. Inside the function, they can update the document and set the permissions. It is important to only give admins execute permission on the function.
BloodThermic
25 May, 2023, 08:58

Can you please send the code in question

BloodThermic
25 May, 2023, 09:00

You will need to the other users id to give them permissions on a document unless you give permissions to other users though teams or everyone

joeyouss
25 May, 2023, 11:18

You are making document, not user. you cannot give read permission to other user. that would let you spam them.

What you can do instead is to make a team and put both users into it. Then give permission to that team

taavisaft
25 May, 2023, 12:39

I have Team "administrators" with CRUD rights to manage collection data anyway. I can do everything except giving permissions to other users in document level.

My specific use-case is: Other users are not allowed to create documents. I create document for them and give them rights to read and edit that document in document level.

taavisaft
25 May, 2023, 12:52

i take NEWUSERID from Auth and want to create a document for that person.

D5
25 May, 2023, 13:05

You should not put user ID in the document ID if you're going to create multiple documents

taavisaft
25 May, 2023, 13:07

In my case each user has only one document that administrator creates and user can edit (if i only could add document permissions 🙂 )

joeyouss
25 May, 2023, 13:43

You can make a function. In Appwrite Function, there is no limitation on how you set permissions.

Then from client, you will execute the function

For example: Create document from client, dont set any permissions Execute function makePublic() and provide it document ID as payload Inside function, update document and set permissions as needed

Make sure to only give admins execute permission on function

taavisaft
25 May, 2023, 18:37

Solved my problem with server side sdk, but i'm going to look into functions also. Tnx!

taavisaft
25 May, 2023, 18:39

[SOLVED] Document Permissions

joeyouss
25 May, 2023, 18:43

Awesome ❤️

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more