I need to verify that the email is confirmed as soon as the user confirms the email, because in the main screen of my application I open a dialog informing the user that he needs to confirm the email in order to use the application.
While it does not confirm the email the dialog is displayed and if it closes the dialog will open again.
I am validating as follows:
auth.service.ts:
export class AuthService {
usuario: any;
constructor(private afAuth: AngularFireAuth) {}
getUser() {
return new Promise((resolve, reject) => {
this.afAuth.auth.onAuthStateChanged((user: any) => {
if (user) {
this.user = user;
}
resolve(user);
},
(response: any) => {
reject(response);
});
});
}
main.component.ts:
export class MainComponent {
constructor( private authService: AuthService,){
this.checkConfirmEmail();
}
checkConfirmEmail() {
this.authService.getUser().then((user: any) => {
if (user.emailVerified == false) {
this.showConfirmEmail();
}
});
}
}
As above, it is only updated user.emailVerified
when I refresh the page, I need a way so I do not have to refresh the page for user.emailVerified
to come up to date.