Back

How do I Update the permissions of a document, that I created In the Cloud?

  • 0
  • Databases
  • Web
aaronksaunders
3 Jul, 2023, 20:41

I am using appwrite.cloud.io

i have created a document... and now I want to give other users access to that document. The selectedItems prop is a list of users that I want to give access to the document.

Thanks

TypeScript
await appwrite.databases.updateDocument(
  import.meta.env.VITE_APPWRITE_DB,
  import.meta.env.VITE_COLLECTION,
  routeParams.id as string,
  {
    members: currentMembers.concat(selectedItems.map((i) => i.$id)),
  },
  selectedItems.map((i) => Permission.read(Role.user(i.$id)))
);

is there something I am missing or can this not be done

TL;DR
The user wants to update the permissions of a document they created in the cloud. The user is trying to use the cloud function route and the server SDK with an API key. However, they discover that they cannot assign a permission they don't have. It is unclear from the documentation what can be updated in the permissions. The user also wants to know how to force a user on a team using the server API. There is a 10 person limit in an hour and the user is dealing with the additional complexity of deep-linking to get the member accepted to the team. Finally, the user asks how to update the permissions of a document
aaronksaunders
3 Jul, 2023, 21:11

How do I Update the permissions of a document, that I created In the Cloud?

Drake
4 Jul, 2023, 00:02

If a user wants to share access to a document, they must create a team, grant that team access, and then invite users to the team. This is to help prevent a user from forcing another user to access something they don't want.

Otherwise, you can use a server SDK to force a user into a team

aaronksaunders
4 Jul, 2023, 00:04

the problem is that you are limited to 10 team requests an hour, also this is for a mobile app so then we introduce the additional lift of dealing with deep-linking to get the member accepted to the team

aaronksaunders
4 Jul, 2023, 00:04

the bigger issue is the 10 person limit in an hour

aaronksaunders
4 Jul, 2023, 00:06

i think there probably are better way to prevent the abuse, if i have created an app and you sign up and i use your userid to add you to a team i dont see that as being abusive

aaronksaunders
4 Jul, 2023, 00:06

but... it is what it is, how do I force a user on a team using the server API... do I just make the same call but from the server?

Drake
4 Jul, 2023, 00:11

Exactly, same call

aaronksaunders
4 Jul, 2023, 01:15

So there is no ability to change permissions on a document after it is created? Or you can only change permission on a document if the permission is based on the owner of the document? It is not clear in the documentation what can be updated in the permissions

Drake
4 Jul, 2023, 01:21

Yes, permissions can be updated, but a user cannot assign a permission they don't have. user:another_users_id is a permission the user doesn't have

aaronksaunders
4 Jul, 2023, 01:23

Can the node.js api assign permissions?

aaronksaunders
4 Jul, 2023, 01:24

With an API key that has the scope

Drake
4 Jul, 2023, 01:24

Server SDK with API key bypasses the restrictions

aaronksaunders
4 Jul, 2023, 01:25

I will try the cloud function route

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