Mahmoud Niypoo
Mahmoud Niypoo

Reputation: 1710

Can I send value with request to Firestore rules

I have to send value with request to check it from Firestore rules , like (Recaptcha to avoid spam) or origin (protect my own firebase api) ! is there any way to do that ?

Upvotes: 2

Views: 2192

Answers (2)

Daniel Storey
Daniel Storey

Reputation: 943

If you want to do your own server-side validation e.g. Recaptcha then you can do the validation in a callable function. If the post data is valid then you can use firebase-admin to access your firestore, and if applicable, return any data at the end of the function.

Upvotes: 1

Frank van Puffelen
Frank van Puffelen

Reputation: 599081

There is no way to pass custom parameters into the Firestore rules. The most common workaround is to pass information as part of the path, although it's definitely kludgy at times.

The best approach for preventing spam is to require your users to log in, and then limit what they can do based on knowing who they are, and knowing what they've done in the past. For example, most apps limit the places users can write to based on their identity, and many apps have a sort-of leveling system where users gradually get more permission as they've been using (and not abusing) the app longer.

Upvotes: 4

Related Questions