简体   繁体   English

对自定义电子邮件使用 firebase 电子邮件验证

[英]Using firebase email verification for a custom email

I am using ionic 3 and firebase authentication using facebook.我正在使用 ionic 3 和使用 facebook 的 firebase 身份验证。 The facebook does not return email id if user did not provided one while signup or did not verify it at all.如果用户在注册时没有提供或根本没有验证,Facebook 不会返回电子邮件 ID。

Our system mandates providing of email id.我们的系统要求提供电子邮件 ID。 So, as a fall back we prompt user to provide the email id.因此,作为后备,我们提示用户提供电子邮件 ID。 As we let user manually provide the email id at this step so there is a need to verify it.由于我们让用户在此步骤手动提供电子邮件 ID,因此需要对其进行验证。

It seems firebase auth sendEmailVerifcation required the email id already in the auth.似乎 firebase auth sendEmailVerifcation 需要 auth 中已经存在的电子邮件 ID。 As our case is specifically handling when this is missing so how can we use this feature to validate the email id?由于我们的案例是在缺少时专门处理的,所以我们如何使用此功能来验证电子邮件 ID?

Any other ideas are welcome too to handle it.也欢迎任何其他想法来处理它。 It is a critical blocker for us as people are misusing our reward system by providing fake email ids.这对我们来说是一个关键的障碍,因为人们通过提供虚假的电子邮件 ID 滥用我们的奖励系统。

I have looked into the sendEmailVerification api but it does not seem to accept any parameter to manually pass the email id.我查看了 sendEmailVerification api,但它似乎不接受任何参数来手动传递电子邮件 ID。

constructor(public navCtrl: NavController, 
              public navParams: NavParams,
              private afAuth: AngularFireAuth,
              private fb: Facebook, 
              private platform: Platform,
              private core:CoreProvider,
              public viewCtrl: ViewController,
              private ddlSvc: DoodleDataProvider,
              private alertCtrl:AlertController,
              private toastCtrl: ToastController) {
                
                //block back button on android
                platform.registerBackButtonAction(() => {
                            
                },1);

                afAuth.authState.subscribe(user => {
                  console.log("auth subscription finished: with user:" + JSON.stringify(user))

                  //go back if user could not be retrieved or manual logout is set to true
                  if (!user || core.manualLogout == true) {   
                    return;
                  }

                  user.sendEmailVerfication() //problem here when email is null
                  console.log("initializing user")
                  this.createUser(user.uid)
                });
  }

Email verification is only for users who sign up with email/password authentication .电子邮件验证适用于使用电子邮件/密码身份验证注册的用户。 The purpose is to validate that the user gave a valid email address at the time they signed up.目的是验证用户在注册时是否提供了有效的电子邮件地址。 You typically want to use email verification after you sign in the user with firebase.auth().createUserWithEmailAndPassword() .您通常希望在使用firebase.auth().createUserWithEmailAndPassword()登录用户后使用电子邮件验证。

Email verification is not available for other authentication providers (such as Facebook), since they have their own way to managing their users' email addresses.电子邮件验证不适用于其他身份验证提供商(例如 Facebook),因为他们有自己的方式来管理用户的电子邮件地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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