Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

login state with signInWithCustomToken shared with browser tabs

Aperta
#3,659 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
angular, firebase, typescript

Direzione di ricerca

Inizia con i metodi login e loginAsPublicUser di FireService, in particolare con le relative chiamate a angularFireAuth.signInWithCustomToken e signOut. Controlla i punti di ingresso dell’autenticazione di AngularFire e il comportamento della persistenza del browser per determinare se è supportato uno stato separato per scheda. Il lavoro è completato quando le sessioni del proprietario dell’account e dell’utente pubblico rimangono isolate tra le schede senza sovrascrivere lo stato di autorizzazione dell’altra.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi

I have an application built with angular fire.
How can I not share login state among tabs in a same browser ?

Application overview

I have a class 'FireService' to login with custom token.
And application let users to login two ways 'as account owner' or 'as public user'.
And if an account owner logins, FireService#login method will be called.
And if a public user logins, FireService#loginAsPublicUser method will be called.

Issue

With same browser but different tab, login as an account owner in a tab 'A' and login as a public user in a tab 'B', the login state was overridden with the public users's and he gets an error due to insufficient permission of firebase rules. Because the owner was trying to access as the public user and blocked by my firebase rules.

I checked the browsers log, after the account owner's stats was overridden, the authorization headers value to start session with firestore was the public user's not the account ownser's.
How can I use login state separately for users different tabs in a same browser?

curl 'https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?VER=8&database=projects%2{project name}%2Fdatabases%2F(default)&RID=*****&CVER=*****X-HTTP-Session-Id=gsessionid&zx=*****&t=1' \
~~~
  -H 'x-client-data: CJ2EywE=' \
  --data-raw 'headers=*****Authorization%3ABearer%20eyJhbGciOiJSU*****'
@Injectable()
export class FireService {

~~~~

  public async login(roomId?: string): Promise<void> {
    if (roomId) {
      this.roomId = roomId;
    }
    const res = await this.serverClient
      .getFirebaseToken(this.roomId)
      .toPromise();

    this.accountId = this.serverClient.getAccountId();

    try {
      await this.angularFireAuth.signInWithCustomToken(res.firebaseToken);
      this.startTokenRefresh(true);
      this.loggedIn = true;
    } catch (error) {
      console.error(error);
    }
  }

  public async loginAsPublicUser(
    participantId: string,
    sharedRoomId: string,
    password: string
  ): Promise<void> {
    this.participantId = participantId;
    this.sharedRoomId = sharedRoomId;
    this.password = password;
    const res = await this.serverClient
      .getPublicFirebaseToken(
        this.participantId,
        this.sharedRoomId,
        this.password
      )
      .toPromise();

    try {
      await this.angularFireAuth.signOut();
      await this.angularFireAuth.signInWithCustomToken(res.firebaseToken);
      this.startTokenRefresh(true);
      this.loggedIn = true;
    } catch (error) {
      console.error(error);
    }
  }
Lingua principale
TypeScript
Stelle
7.8k
Fork
2.2k
Merge medio
3g 6h
PR unite (30g)
5

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di angular/angularfire

Tutte le issue di angular/angularfire

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.