Problems log in in app after changin firestore database

Viewed 62

so I've received a project where to develop they cloned the original firestore database and gave it to us to use whyle developing.

The data in both databases are the same, when I log in trying to use the new database it gives the error that the user does not exist. I'm not sure what is happening here.

the service:

    constructor(
    private firestore: Firestore,
    private router: Router,
    private fns: AngularFireFunctions,
    private auth: AngularFireAuth,
    private db: AngularFirestore
  ) {
    this.auth.authState.subscribe(
      (user) => ((this.userObservable = user, console.log(this.userObservable)))
    );
  }
    
      login(email: any, password: any) {
        this.auth
          .signInWithEmailAndPassword(email, password)
          .then(
            async (res: any) => {
              this.sendEmailVerification(res.user);
              console.log((await res.user.getIdTokenResult()).claims);
              if ((await res.user.getIdTokenResult()).claims.roles == undefined) {
                res.user
                  .getIdTokenResult()
                  .then((res: any) =>
                    this.router.navigate(['dashboardAluno/'])
                  );
              } else if (
                (await res.user.getIdTokenResult()).claims.roles.includes('admin')
              ) {
                this.router.navigate(['admin']);
              } else {
                this.router.navigate(['login']);
              }
            },
            (err: FirebaseError) => this.emitError(err.code)
          )
          .catch((error) => {
            this.emitError(error.message);
          });
      }    
    }

the component.ts:

login(){
    this.user.login(this.email,this.password);
  }

I removed the authentication from the application and I only want to use the data from my firestore database. What's wrong with the code? Do i need to change what i'm calling, because i'm calling AngularFireAuth, should i call the db?

the error that i'm getting in console

enter image description here

0 Answers
Related