Back

Appwrite Cloud Function - User ID Mismatch Issue

  • 0
  • Users
  • Functions
  • Cloud
Drake
27 Jul, 2023, 18:25

how are you executing the function?

TL;DR
Issue: User ID mismatch when executing Appwrite Cloud Function. Solution: The user account in the Appwrite Console is different from the user account used in the client-side app. To ensure the function_user_id matches the user ID in the project, you can create an execution on the client-side. By manually passing the user ID in the payload when executing the function, you can ensure the correct user ID is used on the server-side.
sidney
8 Aug, 2023, 08:42

I am trying to add permission to the user who is deleting a document. I am comparing the user id with the owner of the document, and if they are the same, the user should have permission to delete the document. When I try to log the user id from the server, it is not the same as my user id.

sidney
8 Aug, 2023, 08:44

IN authorization, my user id is different. What is the problem?

sidney
8 Aug, 2023, 12:51

After I execute the function, the document wont be deleted even thought the owner of the document is the same as my user id. Should I use another logic?

Drake
8 Aug, 2023, 15:51

how are you executing the function?

sidney
9 Aug, 2023, 07:06

By sending the json payload after clicking the buttin execute in appwrite

Drake
9 Aug, 2023, 16:31

so in the Appwrite Console. This executes the function as your Console Account. which is not a user in your project.

sidney
17 Aug, 2023, 10:44

how can i solve this?

sidney
17 Aug, 2023, 10:58

what should I do in order for the function_user_id to be the same as the id of the user in the project

safwan
17 Aug, 2023, 11:28

The user account in your console is not the same as the user account as someone who uses your client-side app.

If you want the app's user account, you'll have to create an execution on the client-side.

sidney
17 Aug, 2023, 11:30

is there any other way to get the user id on the server side?

safwan
17 Aug, 2023, 11:32

You can manually pass it in the payload

sidney
17 Aug, 2023, 11:32

Okay thanks

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