convoo / login-fire

An element that allows simple configuration of multiple provider login for firebase
https://webcomponents.org/element/convoo/login-fire
MIT License
59 stars 19 forks source link

Email verification #105

Open esd100 opened 7 years ago

esd100 commented 7 years ago

Firstly, Great component! Thanks for putting it together!

I was wondering if you have an API that can help with email verification or any thoughts on how to implement in conjunction with login-fire.

Thanks

sbeleidy commented 7 years ago

Hi @esd100 - thanks for the suggestion.

I just noticed this: https://firebase.googleblog.com/2017/02/email-verification-in-firebase-auth.html

Maybe there's a way we can incorporate it with the email signup if it's not already automatically incorporated. As for the social sign up I'm not really sure. Happy to get your thoughts and/or PR.

Protoss78 commented 7 years ago

Hi,

I had the same problem when I implemented my last firebase app with login-fire. Basically the firebase API has everything implemented. Whenever a sign up or sign in is successful you get a boolean attribute on the user object that tells you wether the email is verified or not. You could do something like that then:

if (currentUser && !currentUser.emailVerified) {
      currentUser.sendEmailVerification().then(() => {
      this.dispatchEvent(new CustomEvent('displayToast', {
            detail: 'emailVerificationSent',
            bubbles: true,
            composed: true
       }));
  });
}

As far as I've seen the emailVerified could also be false when a social login provider is used. But I guess that is more of a theoretical use case. I the email verification process is included in login-fire I would also consider an attribute to deactivate it if necessary. Just in case somebody wants to handle it on their own or uses a different email verification mechanism.

esd100 commented 7 years ago

Thanks for the suggestions. Yeah, I had seen that firebase googleblog but on the firecast youtube channel a couple of weeks ago (https://www.youtube.com/watch?v=UZ9s_20Hk3U) and thought it was a cool feature.

Actually, when I think about it, it would be cool to have a boolean option to have the email-login element flip to a new form, if the user is signing up, where the user can enter information like first name and last name to add to the displayName property of the firebase user object, kind of like in the little gif example on this github page (https://github.com/firebase/FirebaseUI-Android/blob/master/auth/README.md). Just an idea.