File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed
main/java/com/google/firebase/auth
test/java/com/google/firebase/auth Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ public enum AuthErrorCode {
3636 */
3737 EMAIL_ALREADY_EXISTS ,
3838
39+ /**
40+ * No user record found for the given email, typically raised when
41+ * generating a password reset link using an email for a user that
42+ * is not already registered.
43+ */
44+ EMAIL_NOT_FOUND ,
45+
3946 /**
4047 * The specified ID token is expired.
4148 */
Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ final class AuthErrorHandler extends AbstractHttpErrorHandler<FirebaseAuthExcept
6060 ErrorCode .ALREADY_EXISTS ,
6161 "The user with the provided email already exists" ,
6262 AuthErrorCode .EMAIL_ALREADY_EXISTS ))
63+ .put (
64+ "EMAIL_NOT_FOUND" ,
65+ new AuthError (
66+ ErrorCode .NOT_FOUND ,
67+ "No user record found for the given email" ,
68+ AuthErrorCode .EMAIL_NOT_FOUND ))
6369 .put (
6470 "INVALID_DYNAMIC_LINK_DOMAIN" ,
6571 new AuthError (
Original file line number Diff line number Diff line change @@ -1587,6 +1587,27 @@ public void testHttpErrorWithUnknownCode() {
15871587 }
15881588 }
15891589
1590+ @ Test
1591+ public void testHttpErrorWithEmailNotFoundCode () {
1592+ MockLowLevelHttpResponse response = new MockLowLevelHttpResponse ()
1593+ .setContent ("{\" error\" : {\" message\" : \" EMAIL_NOT_FOUND\" }}" )
1594+ .setStatusCode (400 );
1595+ FirebaseAuth auth = getRetryDisabledAuth (response );
1596+ FirebaseUserManager userManager = auth .getUserManager ();
1597+ try {
1598+ userManager .
getEmailActionLink (
EmailLinkType .
PASSWORD_RESET ,
"[email protected] " ,
null );
1599+ fail ("No exception thrown for HTTP error" );
1600+ } catch (FirebaseAuthException e ) {
1601+ assertEquals (ErrorCode .NOT_FOUND , e .getErrorCode ());
1602+ assertEquals (
1603+ "No user record found for the given email (EMAIL_NOT_FOUND)." ,
1604+ e .getMessage ());
1605+ assertEquals (AuthErrorCode .EMAIL_NOT_FOUND , e .getAuthErrorCode ());
1606+ assertTrue (e .getCause () instanceof HttpResponseException );
1607+ assertNotNull (e .getHttpResponse ());
1608+ }
1609+ }
1610+
15901611 @ Test
15911612 public void testUnexpectedHttpError () {
15921613 MockLowLevelHttpResponse response = new MockLowLevelHttpResponse ()
@@ -2982,3 +3003,4 @@ private interface UserManagerOp {
29823003 }
29833004
29843005}
3006+
You can’t perform that action at this time.
0 commit comments