I'm trying to use the Google Authentication provider and then use the information for an authenticated user in a Database Rule to restrict access to data. For example, say I sign in with my Google id me@gmail.com.
Something kind of like the following (taken from the firestore docs):
let provider = new firebase.auth.GoogleAuthProvider();
let result = await firebase.auth().signInWithPopup(provider);
let token = result.credential.accessToken;
let user = result.user;
// ...
In the above user.email
would be me@gmail.com at this point.
Now how do I use that info in a rule to allow writing to the data. I thought it would be something like:
match /events/{events} {
allow write: if request.auth.uid = // Something?
}
but I cannot figure out how to know what to compare to uid. Ideally it would be the email address (i.e. something human-readable).
My goal here is that I as the administrator keep a list of authorized users, and then they can come log into my app and access the data.