Skip to content

Commit

Permalink
fix(auth,android): too-many-requests code now correctly returned (#3795)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Diarmid <[email protected]>

[publish]
  • Loading branch information
dackers86 authored Jun 18, 2020
1 parent 0edd8f5 commit c799472
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseException;
import com.google.firebase.FirebaseNetworkException;
import com.google.firebase.FirebaseTooManyRequestsException;
import com.google.firebase.auth.ActionCodeResult;
import com.google.firebase.auth.ActionCodeSettings;
import com.google.firebase.auth.AuthCredential;
Expand Down Expand Up @@ -1780,6 +1781,9 @@ private WritableMap getJSError(Exception exception) {
message = invalidEmail;
} else if (exception instanceof FirebaseNetworkException) {
code = "NETWORK_REQUEST_FAILED";
} else if (exception instanceof FirebaseTooManyRequestsException) {
code = "TOO_MANY_REQUESTS";
message = message;
}
}

Expand Down
27 changes: 27 additions & 0 deletions packages/auth/e2e/user.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,33 @@ describe('auth().currentUser', () => {
// Clean up
await firebase.auth().currentUser.delete();
});

// Can only be run/reproduced locally with Firebase Auth rate limits lowered on the Firebase console.
xit('should throw too many requests when limit has been reached', async () => {
await Utils.sleep(10000);
try {
// Setup for creating new accounts
const random = Utils.randString(12, '#aA');
const email = `${random}@${random}.com`;
const pass = random;

const promises = [];

// Create 10 accounts to force the error
[...Array(10).keys()].map($ =>
promises.push(
new Promise(r => r(firebase.auth().createUserWithEmailAndPassword(email + $, pass))),
),
);

await Promise.all(promises);

return Promise.reject('Should have rejected');
} catch (ex) {
ex.code.should.equal('auth/too-many-requests');
return Promise.resolve();
}
});
});

describe('updateProfile()', () => {
Expand Down

0 comments on commit c799472

Please sign in to comment.