First, I'd like to indroduce you one imagined situation:
I'm making a website. For that I'm creating first file: index.html. There i'd like to make a login/register script with Firebase access. I'm giving there email and password inputs and the submit button. Just simple. Now it's time to link them with firebase, so I'm pasting to the file JS snippet, creating createUserWithEmailAndPassword function and enambling Email/password Auth in Firebase console. Now it's time to make login panel. I'm creating same panel but with "Log in" button, creating signInWithEmailAndPassword function and onAuthStateChanged function in which i'm creating the "Getting from Database some information" function to display something for users.
Ok, website is published...
He's a hacker and he wants to destroy whole data from my poor Database, so he copies whole site's source code but he changes getting data function to deleting data function. He logs in with he's own email registered on my website and then activating the deleting function and whole my data is lost...
And finally these question: How to protect? Is this situation possible at all? If not - why not?