Back

The current user is not authorized to perform the requested action.

  • 0
  • Users
  • Databases
  • Web
k_vasen
6 Jan, 2024, 09:35

I am having user cart document with a respective user can read and update permission. Each cart document is 1-1 relationship with user and 1-many realtionship with product documents. When a user removes a product. I am changing the cart products like. this

TypeScript
  const removedProductId ="aadfasdfasdf";
  db.updateDocument({products: document.products.filter(p => p.$id !== removedProductId)}) //assume dbID, colID, docID is given

If there is single product in a cart. It is removing without throwing an error. otherwise it is saying the current user is not authorized to perform the requested action.

TL;DR
The user is receiving an error "the current user is not authorized to perform the requested action" when trying to remove a product from a cart. The error occurs when there is more than one product in the cart. All authenticated users can read, but no users can update. The error seems to be related to the patch request taking some time. When this error occurs, the realtime connection is closed. The user mentions that it worked fine for some time and the respective user can read and update the document. TL;DR: User is not authorized to remove a product from cart when there is more than one product. Realtime connection is closed
Drake
6 Jan, 2024, 21:25

What are the permissions on all related collections and documents?

k_vasen
7 Jan, 2024, 14:17

Respective user can read and update the document.

k_vasen
7 Jan, 2024, 14:19

Actually It worked fine for sometime

k_vasen
7 Jan, 2024, 14:22

When this error occurs. The realtime connection is closed.

k_vasen
7 Jan, 2024, 14:23

Let's say. there are two product in a cart. If I remove any one of the product the error is thrown saying user is not authorized. but when i remove the single product it is working fine

k_vasen
7 Jan, 2024, 14:47

I think patch request is the suspect. Because updateDocument is taking sometime

Drake
7 Jan, 2024, 21:25

What about all related documents?

k_vasen
8 Jan, 2024, 00:13

All authenticated users can read. But no users can update

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