How can update password and emailVerified with AngularFire (firebase)

60 views
Skip to first unread message

Irnel Victoria

unread,
Oct 17, 2019, 11:05:48 PM10/17/19
to Angular and AngularJS discussion
I have the following AngularFireAuth methods.


 // Send email verification when new user sign up
 SendVerificationMail() {
   return this.afAuth.auth.currentUser.sendEmailVerification();
 }

  // Reset Forgot password
 ForgotPassword(email) {
   return this.afAuth.auth.sendPasswordResetEmail(email);
 }



Now I want that when I send the account verification email, to the user to execute the verification link, the emailVerified parameter that its value is false, is updated and changed to true, the same with the ForgotPassword.

Thanks

Sander Elias

unread,
Oct 18, 2019, 2:34:03 AM10/18/19
to Angular and AngularJS discussion
Hi Irnel,

Use the auth service.
I did not test, but something similar to this:
export class AppComponent implements OnInit {
constructor(public afAuth: AngularFireAuth) {
}
login() {
this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider());
}
logout() {
this.afAuth.auth.signOut();
}

ngOnInit() {
this.afAuth.auth.pipe(
filter(Boolean), // filter out non-autoheticated users
map(af => af.auth.isEmailVerified), // I'm only intersted in the verifed part
filter(Boolean), // no logouts
tap(() => /** do what you need */)
).subscribe()
}
}

Regards
Sander

Irnel Victoria

unread,
Oct 18, 2019, 10:41:18 AM10/18/19
to Angular and AngularJS discussion
Hi Sander

I agree with you, I do something similar encapsulate some methods in a service (auth.service.ts)

But the real problem is that I want to update the emailVerified, when the user executes the account verification link in his email account, something similar to the forgot password.

Maybe I do not comment that I keep in a user collection, the user data, and in that collection I want to update the corresponding document in this case the attribute emailVerified and Password.

Regards

Sander Elias

unread,
Oct 18, 2019, 11:14:32 AM10/18/19
to Angular and AngularJS discussion
As Auth is a observable, it will get updated as soon as the user has validated himself.
Reply all
Reply to author
Forward
0 new messages