简体   繁体   中英

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
  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.
  • 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.

例如: {"uid": "iMuWxlrQYbQUoiAsH9N6bCPe37Hi", ..}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM