I am currently writing a chat application online, and I want to be able to disable accounts on the go. Once I disable the account, if the user goes to send a message, currently they are able to. I would like it to only allow write data for authenticated and non-disabled users.
I currently have the code as:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
I have tried using the following:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if auth.token.email_verified == true && auth.token.email.matches(/.*@gmail.com);
}
}
}
and have tried this…
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth == auth.uid;
}
}
}
I am unsure what I need to place inside the rules file for only authenticated and non-disabled accounts can write new messages.
So within the Firebase database, the rule file needs to be changed to allow only authenticated, and non-disabled users to allow to write data (aka: sending messages).
Thank you to everyone who has seen this messaged, and have tried to help!
DRAGEno01 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.