[英]Send email to different email to verify registration using angular firebase
I was able to verify user email before registration.我能够在注册前验证用户电子邮件。 But I want to receive verification email to my email address to complete the registration process.
但我想通过我的电子邮件地址接收验证电子邮件以完成注册过程。 I want to get notification to my email address and after my approval only registration process completes.
我想收到我的电子邮件地址的通知,在我批准后,仅注册过程完成。 I have check email verification: auth-service.ts
我有支票电子邮件验证: auth-service.ts
async SignIn(email,password)
{
const loading =await this.LoadingCtrl.create({
message:'Authenticating..',
spinner:"crescent",
showBackdrop:true
});
loading.present();
this.afauth.setPersistence(firebase.default.auth.Auth.Persistence.LOCAL)
.then(()=>{
this.afauth.signInWithEmailAndPassword(email,password)
.then((data)=>{
if(!data.user.emailVerified){
loading.dismiss();
this.toast('Please check your credentials','warning');
this.afauth.signOut();
}else{
loading.dismiss();
this.router.navigate(['/home']);
}
})
.catch(error=>{
loading.dismiss();
this.toast(error.message,'danger');
})
})
.catch(error=>{
loading.dismiss();
this.toast(error.message,'danger');
});
}
to register:注册:
async register(){
if(this.firstname && this.lastname && this.email && this.password){
const loading =await this.loadingCtrl.create({
message:'Processing...',
spinner:'crescent',
showBackdrop:true
});
loading.present();
this.afauth.createUserWithEmailAndPassword(this.email,this.password)
.then((data)=>{
data.user.sendEmailVerification();
this.afs.collection('user').doc(data.user.uid).set({
'userId':data.user.uid,
'userEmail':this.email,
'userFirstname':this.firstname,
'userLastname':this.lastname
})
.then(()=>{
loading.dismiss();
this.toast('Registration Success','success');
this.router.navigate(['/login']);
})
.catch(error=>{
loading.dismiss();
this.toast(error.message,'danger')
})
})
}
}
It sounds like you want to approve that users can use your app, which is different from allowing them to verify their own email address.听起来您想批准用户可以使用您的应用程序,这与允许他们验证自己的电子邮件地址不同。
While this is a valid use-case, Firebase Authentication doesn't have built-in functionality for this use-case.虽然这是一个有效的用例,但 Firebase 身份验证没有针对此用例的内置功能。
Firebase Authentication only deals with the authentication part, so allowing the user to provide their credentials - and verifying those credentials. Firebase 身份验证仅处理身份验证部分,因此允许用户提供其凭据 - 并验证这些凭据。 To only allow users with a verified email address, or users that you've approved, to use the app is authorization and is part of the application logic you'll have to build yourself.
仅允许具有经过验证的电子邮件地址的用户或您已批准的用户使用该应用程序是授权,并且是您必须自己构建的应用程序逻辑的一部分。
For allowing only approved users access to the app/data, the common process is:为了只允许批准的用户访问应用程序/数据,常见的过程是:
isApproved
field to the profile document you already have that the users can't set themselves.isApproved
字段添加到您已经拥有的用户无法自行设置的配置文件文档中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.