FirebaseUI-Angular icon indicating copy to clipboard operation
FirebaseUI-Angular copied to clipboard

How to handle Multi-tenancy ?

Open florafresco opened this issue 2 years ago • 4 comments

Could you please update the document to handle multi-tenancy ?

florafresco avatar May 10 '23 09:05 florafresco

auth.tenantId = '...';  // https://github.com/firebase/firebaseui-web#multi-tenancy-support.


import { Auth, signOut, user } from '@angular/fire/auth';

@Injectable({
  providedIn: 'root'
})
export class AuthService {

  constructor(
    private auth: Auth,
  ) {
    auth.tenantId = '...';  // https://github.com/firebase/firebaseui-web#multi-tenancy-support.

    user(auth).subscribe(user => {
      console.log('[Auth] user:', user);
    });
  }
}

anisabboud avatar May 14 '23 07:05 anisabboud

I'm currently a bit low on time. It is on my todo list, but I cannot give any timeframe. If it is urgent, feel free to create a PR.

RaphaelJenni avatar Jun 20 '23 09:06 RaphaelJenni

I am also interested in Multi-tenant support, is there any workflow to quickly asign tenantId to somewhere in the code, before the signup/login UI start?

fanyang0356 avatar Jul 09 '23 18:07 fanyang0356

Using [email protected] our imports are slightly different. This works for us:

import firebase from 'firebase/compat/app';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { environment } from 'src/environments/environment';

export class AuthState {
  constructor(private angularFireAuth: AngularFireAuth) {
    // https://github.com/firebase/firebaseui-web#multi-tenancy-support
    if (environment.firebase.auth.tenant) {
      firebase.auth().tenantId = environment.firebase.auth.tenant;
      angularFireAuth.tenantId = Promise.resolve(environment.firebase.auth.tenant);
    }
  }
}

DaveA-W avatar Jun 07 '24 07:06 DaveA-W