iappmaker
iappmaker

Reputation: 3005

What will be there in request.auth.uid?

I am following the answers in the below link to use the "request.auth.uid" to filter the records for an user. Issue in authentication in firebase cloud firestore at user level

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read: if request.auth.uid != null && resource.data.createdBy ==     request.auth.uid;
      allow write: .... 
    }
  }
}

Question

  1. what will be there in request.auth.uid ?
  2. How to pass the values to request.auth.uid which sits in firebase

Upvotes: 2

Views: 2233

Answers (3)

Veeresh Devireddy
Veeresh Devireddy

Reputation: 1145

For example: {"uid": "iMuWxlrQYbQUoiAsH9N6bCPe37Hi", ..}

Upvotes: 0

Taslim Oseni
Taslim Oseni

Reputation: 6263

  • request.auth.uid represents the user ID for the Firebase User.

  • As long as the user is logged in, Firestore automatically sends the values, there is no need for you to manually do that.

Upvotes: 1

Doug Stevenson
Doug Stevenson

Reputation: 317402

  1. request.auth.uid will contain the UID of the user who has been authenticated with Firebase Authentication.
  2. You don't pass values - they come directly from the client when Firebase Authentication is being used. The user must be logged in, then the Firestore SDK will pass along the information.

Upvotes: 2

Related Questions