@@ -34,7 +34,7 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
34
34
}
35
35
36
36
createUser ( creds : EmailPasswordCredentials ) : Promise < FirebaseAuthState > {
37
- return Promise . resolve ( this . _fbAuth . createUserWithEmailAndPassword ( creds . email , creds . password ) )
37
+ return castPromise < firebase . User > ( this . _fbAuth . createUserWithEmailAndPassword ( creds . email , creds . password ) )
38
38
. then ( ( user : firebase . User ) => authDataToAuthState ( user ) ) ;
39
39
}
40
40
@@ -64,17 +64,17 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
64
64
}
65
65
66
66
authWithCustomToken ( token : string ) : Promise < FirebaseAuthState > {
67
- return Promise . resolve ( this . _fbAuth . signInWithCustomToken ( token ) )
67
+ return castPromise < firebase . User > ( ( this . _fbAuth . signInWithCustomToken ( token ) ) )
68
68
. then ( ( user : firebase . User ) => authDataToAuthState ( user ) ) ;
69
69
}
70
70
71
71
authAnonymously ( ) : Promise < FirebaseAuthState > {
72
- return Promise . resolve ( this . _fbAuth . signInAnonymously ( ) )
72
+ return castPromise < firebase . User > ( this . _fbAuth . signInAnonymously ( ) )
73
73
. then ( ( user : firebase . User ) => authDataToAuthState ( user ) ) ;
74
74
}
75
75
76
76
authWithPassword ( creds : EmailPasswordCredentials ) : Promise < FirebaseAuthState > {
77
- return Promise . resolve ( this . _fbAuth . signInWithEmailAndPassword ( creds . email , creds . password ) )
77
+ return castPromise < firebase . User > ( this . _fbAuth . signInWithEmailAndPassword ( creds . email , creds . password ) )
78
78
. then ( ( user : firebase . User ) => authDataToAuthState ( user ) ) ;
79
79
}
80
80
@@ -83,7 +83,7 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
83
83
if ( options . scope ) {
84
84
options . scope . forEach ( scope => providerFromFirebase . addScope ( scope ) ) ;
85
85
}
86
- return Promise . resolve ( this . _fbAuth . signInWithPopup ( providerFromFirebase ) ) ;
86
+ return castPromise < firebase . auth . UserCredential > ( this . _fbAuth . signInWithPopup ( providerFromFirebase ) ) ;
87
87
}
88
88
89
89
/**
@@ -92,16 +92,16 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
92
92
* You should subscribe to the FirebaseAuth object to listen succesful login
93
93
*/
94
94
authWithOAuthRedirect ( provider : AuthProviders , options ?: any ) : Promise < void > {
95
- return Promise . resolve ( this . _fbAuth . signInWithRedirect ( this . _enumToAuthProvider ( provider ) ) ) ;
95
+ return castPromise < void > ( this . _fbAuth . signInWithRedirect ( this . _enumToAuthProvider ( provider ) ) ) ;
96
96
}
97
97
98
98
authWithOAuthToken ( credential : firebase . auth . AuthCredential ) : Promise < FirebaseAuthState > {
99
- return Promise . resolve ( this . _fbAuth . signInWithCredential ( credential ) )
99
+ return castPromise < firebase . User > ( this . _fbAuth . signInWithCredential ( credential ) )
100
100
. then ( ( user : firebase . User ) => authDataToAuthState ( user ) ) ;
101
101
}
102
102
103
103
getRedirectResult ( ) : Observable < firebase . auth . UserCredential > {
104
- return Observable . fromPromise ( Promise . resolve ( this . _fbAuth . getRedirectResult ( ) ) ) ;
104
+ return Observable . fromPromise ( castPromise < firebase . auth . UserCredential > ( this . _fbAuth . getRedirectResult ( ) ) ) ;
105
105
}
106
106
107
107
private _enumToAuthProvider ( providerId : AuthProviders ) : any {
@@ -119,3 +119,8 @@ export class FirebaseSdkAuthBackend extends AuthBackend {
119
119
}
120
120
}
121
121
}
122
+
123
+ // Cast Firebase promises as Zone-patched Promises
124
+ function castPromise < T > ( promiseLike : PromiseLike < T > ) : Promise < T > {
125
+ return Promise . resolve ( promiseLike ) as Promise < T > ;
126
+ }
0 commit comments