I have the following function that is connected to a switch on/off is any way to limit a protentional abuse of this switch ? , lets say a malicious user automate a bot that will keep Turing this switch on and off causing a constant writes do firestore, the other part of the problem is I got changes by using real time data so this will cause a snow ball effect. is there a way to reject writes to db if certain number of the requests has been reached or is there some better practice to handle such a case ?
const SetDisplayDay = (type: string, bool: boolean) => {
const docRef = doc(db, colDynamic(state.user)[0], _authContext.currentUser.uid);
const setDisplay = async () => {
await updateDoc(docRef, {
[type]: bool,
});
};
setDisplay().catch((error) => {
const errorCode = error.code;
alert(errorCode);
});
};