11import { NativeModules , NativeEventEmitter } from 'react-native' ;
2- const FirestackAuth = NativeModules . FirestackAuth ;
3- const FirestackAuthEvt = new NativeEventEmitter ( FirestackAuth ) ;
42
3+ import { Base } from './base' ;
4+ import { default as User } from './user' ;
5+ import promisify from '../utils/promisify' ;
56
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 ) ;
99
1010export default class Auth extends Base {
1111 constructor ( firestack , options = { } ) {
@@ -14,8 +14,10 @@ export default class Auth extends Base {
1414 this . authenticated = false ;
1515 this . _user = null ;
1616
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
1921 FirestackAuthEvt . addListener ( 'listenForAuth' , this . _onAuthStateChanged . bind ( this ) ) ;
2022 FirestackAuth . listenForAuth ( ) ;
2123 }
@@ -45,10 +47,6 @@ export default class Auth extends Base {
4547 onAuthStateChanged ( listener ) {
4648 this . log . info ( 'Creating onAuthStateChanged listener' ) ;
4749 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);
5250 }
5351
5452 /**
@@ -58,8 +56,6 @@ export default class Auth extends Base {
5856 offAuthStateChanged ( listener ) {
5957 this . log . info ( 'Removing onAuthStateChanged listener' ) ;
6058 this . removeListener ( 'onAuthStateChanged' , listener ) ;
61- // this._off('listenForAuth');
62- // return promisify('unlistenForAuth', FirestackAuth)();
6359 }
6460
6561 /**
@@ -103,7 +99,7 @@ export default class Auth extends Base {
10399
104100 /**
105101 * Update the current user's password
106- * @param {string } email the new password
102+ * @param {string } password the new password
107103 * @return {Promise }
108104 */
109105 updatePassword ( password ) {
@@ -112,7 +108,7 @@ export default class Auth extends Base {
112108
113109 /**
114110 * 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)
116112 * @return {Promise }
117113 */
118114 updateProfile ( updates ) {
@@ -159,65 +155,6 @@ export default class Auth extends Base {
159155 return promisify ( 'signInAnonymously' , FirestackAuth ) ( ) ;
160156 }
161157
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-
221158 /**
222159 * Send reset password instructions via email
223160 * @param {string } email The email to send password reset instructions
@@ -231,27 +168,17 @@ export default class Auth extends Base {
231168 * @return {Promise }
232169 */
233170 deleteUser ( ) {
234- return promisify ( 'deleteUser' , FirestackAuth ) ( )
171+ return promisify ( 'deleteUser' , FirestackAuth ) ( ) ;
235172 }
236173
237174 /**
238175 * get the token of current user
239176 * @return {Promise }
240177 */
241178 getToken ( ) {
242- return promisify ( 'getToken' , FirestackAuth ) ( )
179+ return promisify ( 'getToken' , FirestackAuth ) ( ) ;
243180 }
244181
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- }
255182
256183 /**
257184 * Sign the current user out
0 commit comments