0

I'm familiar only with regex when validating strings of data. What I'm trying to do, is validate a specific email address when creating a user in Firebase.

auth.createUserWithEmailAndPassword

  btnSignUp.addEventListener('click', e => {
    // Get email and pass
    const email = txtEmail.value;
    const pass = txtPassword.value;
    const auth = firebase.auth();
    // Sign in
    const promise = auth.createUserWithEmailAndPassword(email, pass);
  });

How can I validate the email that is passed through the EventListener and make sure it matches a specific email address (ex. gmail.com)?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 2
    You can currently not restrict sign-up (authentication) to a specific domain. But you *can* restrict access to the Firebase Database (authorization) to users from a specific domain. See http://stackoverflow.com/questions/36943350/how-do-i-lock-down-firebase-database-to-any-user-from-a-specific-email-domain – Frank van Puffelen Feb 13 '17 at 18:14
  • Frank, this is perfect. Thank you! How does one add the database rules? Is that something you can do in the Firebase console or do I have to use oauth for that? (Edit) Found it, nvm :P –  Feb 13 '17 at 18:29
  • 1
    You set the security rules in your Firebase console: https://console.firebase.google.com/project/_/database/rules – Frank van Puffelen Feb 13 '17 at 18:37

0 Answers0