Hey guys!
Just started a migration away from gapi and off to firebase/angularfire2. I got everything setup, received a console warning not to use af.auth.getAuth() for auth state, and to use subscribe instead, however the subscribe is never triggered? Is this a known bug? Or am I doing something wrong?
service using subscribe
...
// constructor
constructor(private verifyAuthService:VerifyAuthService,
public af:AngularFire) {
// init var
this.emitter$ = new EventEmitter<boolean>();
// subscribe to firebase auth
this.af.auth.subscribe(auth => {
if(auth) {
console.log('user signed in');
this.glAuthModel.isSignedIn = true;
// verify
this.verifyAuthService.verify(af);
// push state
this.pushState();
} else {
console.log('user signed out');
this.glAuthModel.isSignedIn = false;
}
});
}
...
module and firebase init
export const firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: ""
}
export const firebaseAuthConfig = {
provider: AuthProviders.Google,
method: AuthMethods.Popup
}
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule,
AngularFireModule.initializeApp(firebaseConfig, firebaseAuthConfig)],
declarations: [Rvep, Signin, Dashboard],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
FIREBASE_PROVIDERS,
HTTP_PROVIDERS,
rvepRouterProviders,
provide(APP_BASE_HREF, {useValue: '/'}),
provide(LocationStrategy, {useClass: HashLocationStrategy})
],
bootstrap: [Rvep]
})
export class RvepModule {}
I guess I should note, the pop up works just fine, I can signin.
Same issue here, no authData is triggered on component load or after login with Popup, inspecting the _af.auth object shows login was successful.
constructor(public _af: AngularFire) {
this._af.auth.subscribe(auth => console.log(auth));
console.log('auth obj: ', this._af.auth);
}
I've seen this too - seems to be related to [email protected] which is the latest rxjs and is installed by [email protected] which I spent the weekend past moving my project to.
If I drop back to [email protected] which is a peer dependency of [email protected] and angular RC5 then it works again and npm complains less about missing peer dependencies.
@terencewhitenz thanks for the reply! That did it. I appreciate it.
I ran into this problem as well. FYI, [email protected] works just fine for me.
In beta.11 there are some breaking changes, but a quick look in the code does not show any usage of Observable.from or AjaxObservable
@klaascuvelier thanks for the heads up about which package upgrade works. I'll give it a go.
This is still an issue for me, changing the rxjs didn't seem to help. Following the workaround here (using the raw firebase library) allowed me to get something serviceable: https://github.com/angular/angularfire2/issues/472
I'm having this same issue. I downgraded to [email protected] as @klaascuvelier mentioned, but now Angular 2 is broken. @zacharyclaysmith has the right idea at this point.
Most helpful comment
This is still an issue for me, changing the rxjs didn't seem to help. Following the workaround here (using the raw firebase library) allowed me to get something serviceable: https://github.com/angular/angularfire2/issues/472