Home > front end >  React Native App: Email Address Verification Firebase
React Native App: Email Address Verification Firebase

Time:08-26

I have a React Native app running on Firebase and I wanted to make it so that when you sign up you can only use a certain custom domain email like for example "[email protected]". How can I do this?

CodePudding user response:

You can do frontend regex like

const emailRegex = /^[\w-\._\ %] @(customDomain|customDomain1)\./

and before submitting that email in api call, you can test this

const onSubmitAPi = (text) => {

if(!(emailRegex.test(text))){
return null
}

//call api here

}

Hope it helps, feel free for doubts

CodePudding user response:

To check the domain, you can do this in this way.

const email = "[email protected]";
const domain = email.replace(/.*@/, ""); // which gives genius.com

or 

const domain = email.split("@").pop(); // which gives genius.com

I hope this answers you question

  • Related