Skip to content

Angularfire2 and Rxjs Observable Not firing Catch and Complete functions for getting auth data #566

@hllink

Description

@hllink

Hello, i'm getting the auth data on the OnInit method of my page to find out if the user is logged in or not via subscribing to af.auth as showed on this github readme file on the Override configuration / No config Example app section.. it works fine, but im forcing some errors for testing and give the proper treatment to it, i'm signing in with a google account, logging off and logging on with a github account (that have the same email adress) to force the error "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address." but the observable NEVER calls catch or the complete functions for some reason, it just show the following message on my console:
errorjson

the code that subscrible to the auth state:

private subscribleAuth() {
    this.af.auth
        .subscribe(
            auth => {
                this._auth = auth && auth.auth ? auth.auth : null;
                if (this._auth) {
                    this.loginState = 'logged';
                } else {
                    this.loginState = 'login';
                }

            },
            err => {
                console.log('error'),
                    this.loginState = 'error';
            },
            () => { console.log('done.') }
        );
}

Some people on Stackoverflow said that i should use the af.auth.login to return the login state, but i'm using the redirect method, if i call the login every time the page loads to check the user state it redirects to the provider page, gets back to my page and it gets into an infinite loop.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions