1
1
import { NativeModules , NativeEventEmitter } from 'react-native' ;
2
- const FirestackAuth = NativeModules . FirestackAuth ;
3
- const FirestackAuthEvt = new NativeEventEmitter ( FirestackAuth ) ;
4
2
3
+ import { Base } from './base' ;
4
+ import { default as User } from './user' ;
5
+ import promisify from '../utils/promisify' ;
5
6
6
- import promisify from '../utils/promisify'
7
- import { Base } from './base'
8
- import { default as User } from './user' ;
7
+ const FirestackAuth = NativeModules . FirestackAuth ;
8
+ const FirestackAuthEvt = new NativeEventEmitter ( FirestackAuth ) ;
9
9
10
10
export default class Auth extends Base {
11
11
constructor ( firestack , options = { } ) {
@@ -14,8 +14,10 @@ export default class Auth extends Base {
14
14
this . authenticated = false ;
15
15
this . _user = null ;
16
16
17
- this . getCurrentUser ( ) . then ( this . _onAuthStateChanged . bind ( this ) ) . catch ( ( ) => { } ) ;
18
- // always track auth changes internall so we can access them synchronously
17
+ this . getCurrentUser ( ) . then ( this . _onAuthStateChanged . bind ( this ) ) . catch ( ( ) => {
18
+ } ) ;
19
+
20
+ // always track auth changes internally so we can access them synchronously
19
21
FirestackAuthEvt . addListener ( 'listenForAuth' , this . _onAuthStateChanged . bind ( this ) ) ;
20
22
FirestackAuth . listenForAuth ( ) ;
21
23
}
@@ -45,10 +47,6 @@ export default class Auth extends Base {
45
47
onAuthStateChanged ( listener ) {
46
48
this . log . info ( 'Creating onAuthStateChanged listener' ) ;
47
49
this . on ( 'onAuthStateChanged' , listener ) ;
48
- // const sub = this._on('listenForAuth', listener, FirestackAuthEvt);
49
- // FirestackAuth.listenForAuth();
50
- // this.log.info('Listening for onAuthStateChanged events...');
51
- // return promisify(() => sub, FirestackAuth)(sub);
52
50
}
53
51
54
52
/**
@@ -58,8 +56,6 @@ export default class Auth extends Base {
58
56
offAuthStateChanged ( listener ) {
59
57
this . log . info ( 'Removing onAuthStateChanged listener' ) ;
60
58
this . removeListener ( 'onAuthStateChanged' , listener ) ;
61
- // this._off('listenForAuth');
62
- // return promisify('unlistenForAuth', FirestackAuth)();
63
59
}
64
60
65
61
/**
@@ -103,7 +99,7 @@ export default class Auth extends Base {
103
99
104
100
/**
105
101
* Update the current user's password
106
- * @param {string } email the new password
102
+ * @param {string } password the new password
107
103
* @return {Promise }
108
104
*/
109
105
updatePassword ( password ) {
@@ -112,7 +108,7 @@ export default class Auth extends Base {
112
108
113
109
/**
114
110
* Update the current user's profile
115
- * @param {Object } obj An object containing the keys listed [here](https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile)
111
+ * @param {Object } updates An object containing the keys listed [here](https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile)
116
112
* @return {Promise }
117
113
*/
118
114
updateProfile ( updates ) {
@@ -159,65 +155,6 @@ export default class Auth extends Base {
159
155
return promisify ( 'signInAnonymously' , FirestackAuth ) ( ) ;
160
156
}
161
157
162
-
163
- /*
164
- * Old deprecated api stubs
165
- */
166
-
167
-
168
- /**
169
- * @deprecated
170
- * @param args
171
- */
172
- listenForAuth ( ...args ) {
173
- console . warn ( 'Firestack: listenForAuth is now deprecated, please use onAuthStateChanged' ) ;
174
- this . onAuthStateChanged ( ...args ) ;
175
- }
176
-
177
- /**
178
- * @deprecated
179
- * @param args
180
- */
181
- unlistenForAuth ( ...args ) {
182
- console . warn ( 'Firestack: unlistenForAuth is now deprecated, please use offAuthStateChanged' ) ;
183
- this . offAuthStateChanged ( ...args ) ;
184
- }
185
-
186
- /**
187
- * Create a user with the email/password functionality
188
- * @deprecated
189
- * @param {string } email The user's email
190
- * @param {string } password The user's password
191
- * @return {Promise } A promise indicating the completion
192
- */
193
- createUserWithEmail ( ...args ) {
194
- console . warn ( 'Firestack: createUserWithEmail is now deprecated, please use createUserWithEmailAndPassword' ) ;
195
- this . createUserWithEmailAndPassword ( ...args ) ;
196
- }
197
-
198
- /**
199
- * Sign a user in with email/password
200
- * @deprecated
201
- * @param {string } email The user's email
202
- * @param {string } password The user's password
203
- * @return {Promise } A promise that is resolved upon completion
204
- */
205
- signInWithEmail ( ...args ) {
206
- console . warn ( 'Firestack: signInWithEmail is now deprecated, please use signInWithEmailAndPassword' ) ;
207
- this . signInWithEmailAndPassword ( ...args ) ;
208
- }
209
-
210
- /**
211
- * Update the current user's email
212
- * @deprecated
213
- * @param {string } email The user's _new_ email
214
- * @return {Promise } A promise resolved upon completion
215
- */
216
- updateUserEmail ( ...args ) {
217
- console . warn ( 'Firestack: updateUserEmail is now deprecated, please use updateEmail' ) ;
218
- this . updateEmail ( ...args ) ;
219
- }
220
-
221
158
/**
222
159
* Send reset password instructions via email
223
160
* @param {string } email The email to send password reset instructions
@@ -231,27 +168,17 @@ export default class Auth extends Base {
231
168
* @return {Promise }
232
169
*/
233
170
deleteUser ( ) {
234
- return promisify ( 'deleteUser' , FirestackAuth ) ( )
171
+ return promisify ( 'deleteUser' , FirestackAuth ) ( ) ;
235
172
}
236
173
237
174
/**
238
175
* get the token of current user
239
176
* @return {Promise }
240
177
*/
241
178
getToken ( ) {
242
- return promisify ( 'getToken' , FirestackAuth ) ( )
179
+ return promisify ( 'getToken' , FirestackAuth ) ( ) ;
243
180
}
244
181
245
- /**
246
- * Update the current user's profile
247
- * @deprecated
248
- * @param {Object } obj An object containing the keys listed [here](https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile)
249
- * @return {Promise }
250
- */
251
- updateUserProfile ( ...args ) {
252
- console . warn ( 'Firestack: updateUserProfile is now deprecated, please use updateProfile' ) ;
253
- this . updateProfile ( ...args ) ;
254
- }
255
182
256
183
/**
257
184
* Sign the current user out
0 commit comments