Skip to content

Commit

Permalink
fix(auth): make sure onAuth runs in Angular zone
Browse files Browse the repository at this point in the history
There is one place in auth that takes a promise from Firebase,
the promise from getRedirectResult(), and creates an observable
from it. Since Firebase is using their own Promise implementation,
the Promise and its derived observable were running in the root 
zone instead of the Angular zone, causing onAuth changes to not
immediately be propagated to the view. By casting the firebase
Promise to a zone-patched Promise, the observable now runs
in the Angular zone.

Fixes angular#231
  • Loading branch information
jeffbcross committed Jun 21, 2016
1 parent 68d711e commit 78754e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/firebase_sdk_auth_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
}

getRedirectResult(): Observable<firebase.auth.UserCredential> {
return Observable.fromPromise(<Promise<any>>this._fbAuth.getRedirectResult());
return Observable.fromPromise(<Promise<any>>Promise.resolve(this._fbAuth.getRedirectResult()));
}

private _enumToAuthProvider(providerId: AuthProviders): firebase.auth.AuthProvider | FirebaseOAuthProvider {
Expand Down

0 comments on commit 78754e7

Please sign in to comment.