I was trying to build an application in flutter with firebase. I don't want to User to authenticate him/her to firebase authentication.
All I want them to use their phone number as a secret code. Meaning he/she can enter the phone number to view their data without authentication. Without phone number, they cannot read the data.(without OTP too).
Now I have this in firestore rule, so anybody holds the phone number can view the data.
function isUserRef(field) {
return field in resource.data
&& resource.data.mobile == /customers/document/$(request.resource.data.mobile)
}
match /customers/{document=**} {
allow read : if isUserRef(request.resource.data.mobile);
}
request resource data contain as below.
User{
"id" : null,
"mobile" : "7878445778"
}
But the above rule still doesn't match the document based on his/her mobile number. I don't want to user to authenticate at all. It's simple application were data is not a concern.
Any help appreciated!!. Thanks.