3

The following is the code sample. The goal is to create a user with email and password, for a specific tenantId:

import { Observable } from 'rxjs';
import { initializeApp } from 'firebase/app';

const app = initializeApp(JSON.parse(process.env.FIREBASE_CONFIG));
const firebaseAuth = getAuth();

firebaseAuth.tenantId = "foo";

const createUserObserver = (email, pass) => {
 const observer = new Observable(subscriber => {
  createUserWithEmailAndPassword(firebaseAuth, email, pass)
   .then((userCredential) => {
     subscriber.next(userCredential);
     subscriber.complete();
   })
   .catch((error) => {
     subscriber.error(error);
     subscriber.complete();
    });
  });
  
  return observer;
}

const createUser = () => {
 createUserObserver("foo@bar.com", "123abc*")
  .subscribe({
    next: v => handleUserCreated(v),
    error: e => handleError(e),
    complete: () => console.log('Completed')
  });
}

createUser();

Everything goes successfully, I get the correct user credentials and the returned user object has the correct tenantId on it as well. But, the chrome console error throws auth/tenant-id-mismatch. I have only one tenant setup at the project so far and there are no other tenant ids as well. I logged the tenant id at the firebaseAuth object as well and that seems to be the exact tenantId I receive back from firebase.

I cant seem to trace where the following error is coming from.

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
skypen
  • 199
  • 2
  • 10

0 Answers0