Skip to content

auth().onAuthStateChanged() throws TypeError after clearing LocalStorage #178

@mnlfischer

Description

@mnlfischer
  • Operating System version: win10 1703
  • Firebase SDK version: 4.4.0
  • Firebase Product: auth

TypeError: Cannot read property 'indexOf' of null in auth.js after cleaing LocalStorage

Steps to reproduce:

I'm not sure if this is the expected behavior but after clearing the LocalStorage, I got an TypeError 'indexOf' of null. I expected null in case of missing LocalStorage user element.

Relevant Code:

@Injectable()
export class AuthService {
  isAuthenticated: boolean;

  constructor() {
    firebase.auth().onAuthStateChanged((user: firebase.User) => {
      if (user) {
        this.isAuthenticated = true;
      } else {
        this.isAuthenticated = false;
      }
    });
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions