Skip to content

Commit 4df5f2e

Browse files
committed
fix double callback issue on signInWithEmail
1 parent 5d6a218 commit 4df5f2e

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

android/src/main/java/io/fullstack/firestack/FirestackAuth.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@ public String getName() {
6161

6262
@ReactMethod
6363
public void listenForAuth() {
64-
if (mAuthListener == null) {
64+
if (mAuthListener == null || mAuth == null) {
6565
mAuthListener = new FirebaseAuth.AuthStateListener() {
6666
@Override
6767
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
6868
WritableMap msgMap = Arguments.createMap();
6969
msgMap.putString("eventName", "listenForAuth");
7070

7171
if (FirestackAuthModule.this.user != null) {
72+
// TODO move to helper
7273
WritableMap userMap = getUserMap();
73-
7474
msgMap.putBoolean("authenticated", true);
7575
msgMap.putMap("user", userMap);
7676

@@ -92,6 +92,7 @@ public void unlistenForAuth(final Callback callback) {
9292
if (mAuthListener != null) {
9393
mAuth.removeAuthStateListener(mAuthListener);
9494

95+
// TODO move to helper
9596
WritableMap resp = Arguments.createMap();
9697
resp.putString("status", "complete");
9798

@@ -140,12 +141,6 @@ public void onComplete(@NonNull Task<AuthResult> task) {
140141
userExceptionCallback(ex, callback);
141142
}
142143
}
143-
})
144-
.addOnFailureListener(new OnFailureListener() {
145-
@Override
146-
public void onFailure(@NonNull Exception ex) {
147-
userExceptionCallback(ex, callback);
148-
}
149144
});
150145
}
151146

0 commit comments

Comments
 (0)