I've set up Firebase email/password authentication successfully using firebase-ui.
var uiConfig = {
signInSuccessUrl: '<?php echo $url; ?>',
signInOptions: [
// Leave the lines as is for the providers you want to offer your users.
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
firebase.auth.FacebookAuthProvider.PROVIDER_ID,
firebase.auth.EmailAuthProvider.PROVIDER_ID
],
// Terms of service url.
tosUrl: '<your-tos-url>'
};
// Initialize the FirebaseUI Widget using Firebase.
var ui = new firebaseui.auth.AuthUI(firebase.auth());
// The start method will wait until the DOM is loaded.
ui.start('#firebaseui-auth-container', uiConfig);
but for security reasons I want the user to confirm her/his email.But fromthe above code it doesn't send a verfication mail to user. So I've used following method to send a verification mail to user if he/she not verified his/her account mail.
firebase.auth().onAuthStateChanged(function(user) {
if (user && user.uid != currentUid) {
if (firebase.auth().currentUser.emailVerified) {
currentUid = user.uid;
else {
//---- HERE YOU SEND THE EMAIL
firebase.auth().currentUser.sendEmailVerification();
}
But when I used this code it sends multiple verification mails for same account. Which means this method runs each time a user reload the page. It would be really greatful if someone could help me to identify whether verification mail sent or not for a specific user using firebase.
sendEmailVerification()
. If you want to throttle this sending, you'll have to implement a mechanism for that yourself. – Frank van PuffelensendEmailVerification()
is only called in test code (one of the advantages of FirebaseUI being open-source is that you can search for this type of thing yourself), so it doesn't seem to be a feature. There is a feature request for it already, so you might want to chime/vote there. – Frank van Puffelen