1

I am creating a application for my institute and i want people to access this application through the institute's mail server only. I don't want them to access this application by using their personal mail id's. I am creating my app in react native and firebase. So how to give authentication in firebase that take only institute mail id's only. So what could be the possible solutions for this

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Jeet Mehta
  • 25
  • 5

2 Answers2

1

Do you specifically need Firebase to prevent non-institute emails from being used?

If not then you can just check the email address on the client before registering.

So the method assigned to the 'onPress' prop of your submit button might look something like:

onPress = () => {
  if (!this.state.email.endsWith(`@my_institute.com`)) {
    alert('Invalid email');
    return;
  }

  auth()
    .signInWithEmailAndPassword(this.state.email, this.state.password)
    .catch(err => console.error(err));
}
Flagship1442
  • 1,688
  • 2
  • 6
  • 13
1

There is no way to restrict sign-in with Firebase Authentication to users from a specific domain. See:

But if you require users to verify their email address, you can restrict what data they can access in your back-end. If you're storing you data in one of the Firebase databases, you can find examples of doing that in Firebase's server-side security rules here:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807