File tree 2 files changed +22
-5
lines changed
android/src/main/java/io/fullstack/firestack
2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -627,8 +627,7 @@ private WritableMap getUserMap() {
627
627
userMap .putString ("uid" , uid );
628
628
userMap .putString ("providerId" , provider );
629
629
userMap .putBoolean ("emailVerified" , verified );
630
-
631
-
630
+
632
631
if (name != null ) {
633
632
userMap .putString ("name" , name );
634
633
}
Original file line number Diff line number Diff line change @@ -14,12 +14,30 @@ 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 ( ( ) => {
17
+ // start listening straight away
18
+ // generally though the initial event fired will get ignored
19
+ // but this is ok as we fake it with the getCurrentUser below
20
+ FirestackAuth . listenForAuth ( ) ;
21
+
22
+ this . getCurrentUser ( ) . then ( ( u ) => {
23
+ const authResult = { authenticated : ! ! u } ;
24
+ if ( u ) authResult . user = u ;
25
+ this . _onAuthStateChanged ( authResult ) ;
26
+ this . _startListening ( ) ;
27
+ } ) . catch ( ( ) => {
28
+ // todo check if error contains user disabled message maybe and add a disabled flag?
29
+ this . _onAuthStateChanged ( { authenticated : false } ) ;
30
+ this . _startListening ( ) ;
18
31
} ) ;
32
+ }
19
33
20
- // always track auth changes internally so we can access them synchronously
34
+ /**
35
+ * Internal function begin listening for auth changes
36
+ * only called after getting current user.
37
+ * @private
38
+ */
39
+ _startListening ( ) {
21
40
FirestackAuthEvt . addListener ( 'listenForAuth' , this . _onAuthStateChanged . bind ( this ) ) ;
22
- FirestackAuth . listenForAuth ( ) ;
23
41
}
24
42
25
43
/**
You can’t perform that action at this time.
0 commit comments