Getting the MultiFactorAuth property on a User with Angular Firebase Library angularfire

40 Views Asked by At

Im using Firebase as a User Database for my WebApp. Since im using Angular (16) and there is an offical library/wrapper from angular: https://github.com/angular/angularfire/

The documentation of this lib is not that optimal and in my web app im trying to find out if the user that is logged in has any multi-factor-auth enabled or not. Im not talking during the login process but in general. On the normal firebase the user had a property called "multiFactor", which is not there in the User of that lib.

So the question is now, how can i access the state of multiFactor of a user? hope i gave enough info.

Thanks all.

The things i tried was just checking the user object that i get from authenticating and checking all the properties on the auth and the user

1

There are 1 best solutions below

0
Roy McGregor On

Once you have the user logged in you need to create a multiFactorUser from that current user.

import * as firebase from '@angular/fire/auth';

constructor(private authentication: firebase.Auth) {
}

public async register() {
 const currentUser = this.authentication.currentUser;
 if (currentUser) {
     const multiFactorUser = firebase.multiFactor(currentUser);
     const multieFactorSession = await multiFactorUser.getSession(); 
 }
}