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
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 Authentication only deals with the authentication part, so allowing the user to provide their credentials - and verifying those credentials. 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.