Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fake users in firebase with @gmail.com accounts

I have a firebase project. The next sign-in methods auth are enabled:

  • Google
  • Facebook
  • Apple
  • Anonymous

A mobile app interacts with the firebase.

Each day I get some weird new users sign-ups with fake accounts with the pattern: [name][numbers]@gmail.com. They don't do anything except sign up via google oauth once.

Is it possible to prevent it? Maybe I missed something with the google oauth configuration?

Updated:

Also, I noticed that these sign-ups started to occur when I had sent out the mobile app to google/apple verification. May these two events are correlated?

like image 350
Andrei Kovrov Avatar asked Sep 15 '20 23:09

Andrei Kovrov


People also ask

How can I get user details from Firebase?

If the user login with a custom "email/password" you don't know anything else about that user (apart from the unique user id). If a user login with Facebook, or with Google sign in, you can get other information like the profile picture url. It is explained here: firebase.google.com/docs/auth/android/… .

Is email authentication free in Firebase?

Auth is free. Firebase Authentication service is free in all plans.


2 Answers

If you are sure those fake users have a specific pattern from their email address, I would make a trigger function on Cloud Functions for Firebase.

You can use functions.auth.user().onCreate() event handler like below.

exports.checkFakeUser = functions.auth.user().onCreate((user) => {
  // You can check if the user has suspicious email patterns and delete them here.
});

Or you can also make a Schedule function on Cloud Functions for Firebase and daily check if there are fake users and automatically delete them.

Plus, it would be a good step if you figure out that fake users still joining even you didn't expose your mobile app anywhere if you want to find out the reason how they are joining.

like image 195
wonsuc Avatar answered Oct 05 '22 07:10

wonsuc


Add the following Cloud Function will help you on check the email and delete the fake user

    exports.checkFakeUser = functions.auth.user().onCreate((user) => {
        const list = user.email.split(".")[1].split("@")
        const isFake = list[0].length === 5 && list[1] === 'gmail'
        if(isFake){
            admin.auth().deleteUser(user.uid)
            .catch(function(error) {
                console.log('Error deleting user:', error);
            });
        }
    });
like image 20
Ivan Krupik Avatar answered Oct 05 '22 08:10

Ivan Krupik