简体   繁体   中英

React Native App: Email Address Verification Firebase

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 "johndoe@genius.com". How can I do this?

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

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

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

or 

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

I hope this answers you question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM