0
votes

I am talking about uid that we access like this in security rules request.auth.uid

I know there is a method to make firestore login using email and password signInWithEmailAndPassword

I want to know how I pass uid that we access in security rules in request.auth Thank You So Much In Advance

1
The uid is being set as soon as you use any authentication methods from Firebase via angularfire or the js-sdk, so at the security rules, you will always have this request.auth.uid available. Please take a look at this video to learn more about Firestore Security Rules.KingDarBoja

1 Answers

0
votes

If you're using Firebase Authentication, the UID (and the entire auth token) are automatically passed to the security rules of Firestore. They're available in request.auth in your rules, so for example: request.auth.uid for the UID of the user who made the request.

Outside of signing in with Firebase Authentication, there is no way for your code to influence the auth.request.uid. If there was, that'd be a huge security risk - as it'd allow malicious users to pass any UID they'd want and gain access to data they aren't authorized to.