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 {
36
36
*/
37
37
EMAIL_ALREADY_EXISTS ,
38
38
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
+
39
46
/**
40
47
* The specified ID token is expired.
41
48
*/
Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ final class AuthErrorHandler extends AbstractHttpErrorHandler<FirebaseAuthExcept
60
60
ErrorCode .ALREADY_EXISTS ,
61
61
"The user with the provided email already exists" ,
62
62
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 ))
63
69
.put (
64
70
"INVALID_DYNAMIC_LINK_DOMAIN" ,
65
71
new AuthError (
Original file line number Diff line number Diff line change @@ -1587,6 +1587,27 @@ public void testHttpErrorWithUnknownCode() {
1587
1587
}
1588
1588
}
1589
1589
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
+
1590
1611
@ Test
1591
1612
public void testUnexpectedHttpError () {
1592
1613
MockLowLevelHttpResponse response = new MockLowLevelHttpResponse ()
@@ -2982,3 +3003,4 @@ private interface UserManagerOp {
2982
3003
}
2983
3004
2984
3005
}
3006
+
You can’t perform that action at this time.
0 commit comments