Back

Is it possible to prevent a document create from a Function?

  • 0
  • Self Hosted
saricden
15 Jun, 2023, 01:07

I'm wondering:

Is it possible to block a document create from a server function that is subscribed to the create event?

As means of an additional layer of security?

For my use case it would be to prevent muted users from sending messages during their mute period.

TL;DR
The user wants to know if it's possible to prevent a document from being created using a server function. Several suggestions are given, including using a validation function and changing permissions in the collection. However, it is noted that Appwrite functions cannot be placed between processes. There is no clear solution provided in the thread.
Binyamin
15 Jun, 2023, 01:08

Like a middleware-function? That will be cool but as of now Appwrite function can't go in between some processes.

What you can do now:

  1. Change permission to a collection - by specific roles for example.
  2. Delete them right away - this is probably not what you've been looking for.
Drake
15 Jun, 2023, 01:11

i typically prevent creation via the API and expose a function to create the document. the function can do any validation and only create the document if validation passes

saricden
15 Jun, 2023, 02:18

Okay, makes sense, thanks guys πŸ™‚

animeyeet
15 Jun, 2023, 04:49

create 2 fx. make one for validation and other whatever you like. second fx tigger validation fx and validation fx trigger doc. creation

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