remove getToken calling from promiseWithUser (was getting called every auth method, not sure why it was here)

This commit is contained in:
Salakar 2017-03-13 20:14:17 +00:00
parent 15167a4f81
commit 7715b2c061
1 changed files with 9 additions and 18 deletions

View File

@ -96,6 +96,7 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
/** /**
* Removes the current auth state listener * Removes the current auth state listener
*
* @param callback * @param callback
*/ */
@ReactMethod @ReactMethod
@ -111,6 +112,7 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
/** /**
* signOut * signOut
*
* @param promise * @param promise
*/ */
@ReactMethod @ReactMethod
@ -125,6 +127,7 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
/** /**
* signInAnonymously * signInAnonymously
*
* @param promise * @param promise
*/ */
@ReactMethod @ReactMethod
@ -150,6 +153,7 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
/** /**
* createUserWithEmailAndPassword * createUserWithEmailAndPassword
*
* @param email * @param email
* @param password * @param password
* @param promise * @param promise
@ -564,6 +568,7 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
/** /**
* Resolves or rejects an auth method promise without a user (user was missing) * Resolves or rejects an auth method promise without a user (user was missing)
*
* @param promise * @param promise
* @param isError * @param isError
*/ */
@ -576,29 +581,15 @@ public class RNFirebaseAuth extends ReactContextBaseJavaModule {
} }
/** /**
* promiseWithUser
*
* @param user * @param user
* @param promise * @param promise
*/ */
private void promiseWithUser(final FirebaseUser user, final Promise promise) { private void promiseWithUser(final FirebaseUser user, final Promise promise) {
if (user != null) { if (user != null) {
user.getToken(true)
.addOnSuccessListener(new OnSuccessListener<GetTokenResult>() {
@Override
public void onSuccess(GetTokenResult getTokenResult) {
Log.d(TAG, "promiseWithUser:getToken:success");
WritableMap userMap = firebaseUserToMap(user); WritableMap userMap = firebaseUserToMap(user);
userMap.putString("token", getTokenResult.getToken());
promise.resolve(userMap); promise.resolve(userMap);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
WritableMap error = authExceptionToMap(exception);
Log.e(TAG, "promiseWithUser:getToken::failure", exception);
promise.reject(error.getString("code"), error.getString("message"), exception);
}
});
} else { } else {
promiseNoUser(promise, true); promiseNoUser(promise, true);
} }