|
76 | 76 | * @return {Promise<Object>} A promise fulfilled with an object containing authentication data. |
77 | 77 | */ |
78 | 78 | signInWithCustomToken: function(authToken) { |
79 | | - return this._utils.Q(this._auth.signInWithCustomToken(authToken).then); |
| 79 | + return this._utils.promise.when(this._auth.signInWithCustomToken(authToken)); |
80 | 80 | }, |
81 | 81 |
|
82 | 82 | /** |
|
85 | 85 | * @return {Promise<Object>} A promise fulfilled with an object containing authentication data. |
86 | 86 | */ |
87 | 87 | signInAnonymously: function() { |
88 | | - return this._utils.Q(this._auth.signInAnonymously().then); |
| 88 | + return this._utils.promise.when(this._auth.signInAnonymously()); |
89 | 89 | }, |
90 | 90 |
|
91 | 91 | /** |
|
96 | 96 | * @return {Promise<Object>} A promise fulfilled with an object containing authentication data. |
97 | 97 | */ |
98 | 98 | signInWithEmailAndPassword: function(email, password) { |
99 | | - return this._utils.Q(this._auth.signInWithEmailAndPassword(email, password).then); |
| 99 | + return this._utils.promise.when(this._auth.signInWithEmailAndPassword(email, password)); |
100 | 100 | }, |
101 | 101 |
|
102 | 102 | /** |
|
106 | 106 | * @return {Promise<Object>} A promise fulfilled with an object containing authentication data. |
107 | 107 | */ |
108 | 108 | signInWithPopup: function(provider) { |
109 | | - return this._utils.Q(this._auth.signInWithPopup(this._getProvider(provider)).then); |
| 109 | + return this._utils.promise.when(this._auth.signInWithPopup(this._getProvider(provider))); |
110 | 110 | }, |
111 | 111 |
|
112 | 112 | /** |
|
116 | 116 | * @return {Promise<Object>} A promise fulfilled with an object containing authentication data. |
117 | 117 | */ |
118 | 118 | signInWithRedirect: function(provider) { |
119 | | - return this._utils.Q(this._auth.signInWithRedirect(this._getProvider(provider)).then); |
| 119 | + return this._utils.promise.when(this._auth.signInWithRedirect(this._getProvider(provider))); |
120 | 120 | }, |
121 | 121 |
|
122 | 122 | /** |
|
126 | 126 | * @return {Promise<Object>} A promise fulfilled with an object containing authentication data. |
127 | 127 | */ |
128 | 128 | signInWithCredential: function(credential) { |
129 | | - return this._utils.Q(this._auth.signInWithCredential(credential).then); |
| 129 | + return this._utils.promise.when(this._auth.signInWithCredential(credential)); |
130 | 130 | }, |
131 | 131 |
|
132 | 132 | /** |
|
181 | 181 | * rejected if the client is unauthenticated and rejectIfAuthDataIsNull is true. |
182 | 182 | */ |
183 | 183 | _routerMethodOnAuthPromise: function(rejectIfAuthDataIsNull) { |
184 | | - var utils = this._utils, self = this; |
| 184 | + var self = this; |
185 | 185 |
|
186 | 186 | // wait for the initial auth state to resolve; on page load we have to request auth state |
187 | 187 | // asynchronously so we don't want to resolve router methods or flash the wrong state |
|
191 | 191 | // to the current auth state and not a stale/initial state |
192 | 192 | var authData = self.getAuth(), res = null; |
193 | 193 | if (rejectIfAuthDataIsNull && authData === null) { |
194 | | - res = utils.reject("AUTH_REQUIRED"); |
| 194 | + res = self._utils.reject("AUTH_REQUIRED"); |
195 | 195 | } |
196 | 196 | else { |
197 | | - res = utils.resolve(authData); |
| 197 | + res = self._utils.resolve(authData); |
198 | 198 | } |
199 | 199 | return res; |
200 | 200 | }); |
|
274 | 274 | * uid of the created user. |
275 | 275 | */ |
276 | 276 | createUserWithEmailAndPassword: function(email, password) { |
277 | | - return this._utils.Q(this._auth.createUserWithEmailAndPassword(email, password).then); |
| 277 | + return this._utils.promise.when(this._auth.createUserWithEmailAndPassword(email, password)); |
278 | 278 | }, |
279 | 279 |
|
280 | 280 | /** |
|
286 | 286 | updatePassword: function(password) { |
287 | 287 | var user = this.getAuth(); |
288 | 288 | if (user) { |
289 | | - return this._utils.Q(user.updatePassword(password).then); |
| 289 | + return this._utils.promise.when(user.updatePassword(password)); |
290 | 290 | } else { |
291 | 291 | return this._utils.reject("Cannot update password since there is no logged in user."); |
292 | 292 | } |
|
301 | 301 | updateEmail: function(email) { |
302 | 302 | var user = this.getAuth(); |
303 | 303 | if (user) { |
304 | | - return this._utils.Q(user.updateEmail(email).then); |
| 304 | + return this._utils.promise.when(user.updateEmail(email)); |
305 | 305 | } else { |
306 | 306 | return this._utils.reject("Cannot update email since there is no logged in user."); |
307 | 307 | } |
|
315 | 315 | deleteUser: function() { |
316 | 316 | var user = this.getAuth(); |
317 | 317 | if (user) { |
318 | | - return this._utils.Q(user.delete().then); |
| 318 | + return this._utils.promise.when(user.delete()); |
319 | 319 | } else { |
320 | 320 | return this._utils.reject("Cannot delete user since there is no logged in user."); |
321 | 321 | } |
|
329 | 329 | * @return {Promise<>} An empty promise fulfilled once the reset password email is sent. |
330 | 330 | */ |
331 | 331 | sendPasswordResetEmail: function(email) { |
332 | | - return this._utils.Q(this._auth.sendPasswordResetEmail(email).then); |
| 332 | + return this._utils.promise.when(this._auth.sendPasswordResetEmail(email)); |
333 | 333 | } |
334 | 334 | }; |
335 | 335 | })(); |
0 commit comments