File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
android/src/main/java/io/fullstack/firestack Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -627,8 +627,7 @@ private WritableMap getUserMap() {
627627 userMap .putString ("uid" , uid );
628628 userMap .putString ("providerId" , provider );
629629 userMap .putBoolean ("emailVerified" , verified );
630-
631-
630+
632631 if (name != null ) {
633632 userMap .putString ("name" , name );
634633 }
Original file line number Diff line number Diff line change @@ -14,12 +14,30 @@ export default class Auth extends Base {
1414 this . authenticated = false ;
1515 this . _user = null ;
1616
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 ( ) ;
1831 } ) ;
32+ }
1933
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 ( ) {
2140 FirestackAuthEvt . addListener ( 'listenForAuth' , this . _onAuthStateChanged . bind ( this ) ) ;
22- FirestackAuth . listenForAuth ( ) ;
2341 }
2442
2543 /**
You can’t perform that action at this time.
0 commit comments