Prevent duplicate entry in firebase database [duplicate] - firebase

This question already has answers here:
How do you prevent duplicate user properties in Firebase?
(2 answers)
Closed 3 years ago.
I want to add rule so that no duplicate rdate is added in database.
I am beginner to firebase and i don't know how to create rules for stopping duplicate.

This isn't possible with security rules, because rules don't have a way of performing queries for other nodes. The only way you can access other nodes in the database is using val() at the specific location you're interested in knowing about, but you have to know the full path to that specific location.
Your alternative is to make a request through a backend you control (such as Cloud Functions), and have that backend perform the query to check if there is a conflict.

Related

Is it possible to create a document template in Firestore? [duplicate]

This question already has answers here:
Firestore Documents Template [duplicate]
(1 answer)
Firebase Firestore: Is there a way to enforce required fields for all documents in a collection?
(3 answers)
Closed 7 months ago.
I need to add many documents to my firestore database and they all need the exact same fields. Is it possible to create a "template" so I don't need to keep adding the same fields to each document I make?
There is no concept of a document template in Firestore. If you need this, most devs create a simple administrative app, and you could of course also consider using one of the 3rd party content management systems that support Firestore.

Using Firestore: How to prevent a malicious ip from sending too many requests? [duplicate]

This question already has an answer here:
How do I implement a write rate limit in Cloud Firestore security rules?
(1 answer)
Closed 1 year ago.
Because I didn't see any other posts that specifically asked this question phrased in this way, I thought I might ask.
An example of "too many requests" might be a malicious user altering the client-side code so that it creates a new user (stored in Firecloud) as frequently as possible.
Like Frank van Puffelen pointed out, this has already been answered and is found here: How do I implement a write rate limit in Cloud Firestore security rules?
The keywords used in this post are different than the one used in the post linked above, so I feel like it's worth it to keep this post around just in case someone gets here via a Google search using these keywords.

Text search on firestore document field [duplicate]

This question already has answers here:
Firestore Comparison Operators - contains, does not contain, starts with
(2 answers)
Closed 4 years ago.
I am using cloud firestore as my database for my angular application. I wanted to implement text based search but the only option I see is using Angolia but I don’t want to use a 3rd party service. Is it possible to implement text search with just the functionality provided by firestore. Even if it returns the object by matching the first characters will work for me it does not have to be a “contain” query.
Firestore does not support full text search in any form. That's why the documentation suggests the use of another service.

Does Firebase storage offer unique Id's for files? [duplicate]

This question already has answers here:
Store files with unique/random names
(5 answers)
Closed 6 years ago.
So the realtime database offers me a direct way to reference a node by using its ID. Until now though, I have only seen examples of Firebase storage using the filename to create a reference. What if two files have the same name though? Must I prevent the user from uploading duplicate filenames? The URL is unique but as far as I know you aren't able to create a reference to the file based on it. Is there something I'm missing because this doesn't seem right to me. Thanks for your help.
In Firebase Storage it is up to you to determine the file name when uploading the file. There is no built-in method to generate a unique filename for Firebase Storage (like the push() method in the database).
If you have two references to the same path, they will be referring to the same file in Firebase Storage.
If you want globally unique filenames, you'll have to generate those yourself. One way would be to use the Firebase Database's push() method, but you can also use any other GUID-generator for your platform of choice.

How to keep track of users that belong to different companies in asp.net-mvc? [duplicate]

This question already has answers here:
ASP.NET MVC - Set custom IIdentity or IPrincipal
(9 answers)
Closed 6 years ago.
I have an application where I have created a authhenticaton login with the help of entityframework IDENTITY.
The point of this application is alot but for the relevance of this question it is that it should be used by several users that even perhaps belog to different companies. For this I assigned an OrgId in the usertable in the DB.
The thing I am trying to figure out is the best way to get this OrgId.
Every time a user logs in I get this info but I don't want to check the users info with each request or save to the db.
While searching for this i stumbled accross using a global variable like so:
ASP.NET MVC Global Variables
Which gives me an idea of how I can do this but I don't want to come to an impass weeks from now and realize that this was not the best way to go about doing this.
I'm searching for a good way of accomplishing what I am trying to do, pros, cons etc.
If you're using ASP.NET Identity, I suggest using claims to set additional information about the user.
You can set the claims once the authentication is successful.
See the following for more information:
Link 1
Link 2

Resources