diff --git a/auth/user_mgt.go b/auth/user_mgt.go index d5b430be..a756a494 100644 --- a/auth/user_mgt.go +++ b/auth/user_mgt.go @@ -320,6 +320,7 @@ const ( idTokenRevoked = "id-token-revoked" insufficientPermission = "insufficient-permission" invalidDynamicLinkDomain = "invalid-dynamic-link-domain" + invalidEmail = "invalid-email" phoneNumberAlreadyExists = "phone-number-already-exists" projectNotFound = "project-not-found" sessionCookieRevoked = "session-cookie-revoked" @@ -354,6 +355,11 @@ func IsInvalidDynamicLinkDomain(err error) bool { return internal.HasErrorCode(err, invalidDynamicLinkDomain) } +// IsInvalidEmail checks if the given error was due to an invalid email. +func IsInvalidEmail(err error) bool { + return internal.HasErrorCode(err, invalidEmail) +} + // IsPhoneNumberAlreadyExists checks if the given error was due to a duplicate phone number. func IsPhoneNumberAlreadyExists(err error) bool { return internal.HasErrorCode(err, phoneNumberAlreadyExists) @@ -396,6 +402,7 @@ var serverError = map[string]string{ "EMAIL_EXISTS": emailAlreadyExists, "INSUFFICIENT_PERMISSION": insufficientPermission, "INVALID_DYNAMIC_LINK_DOMAIN": invalidDynamicLinkDomain, + "INVALID_EMAIL": invalidEmail, "PERMISSION_DENIED": insufficientPermission, "PHONE_NUMBER_EXISTS": phoneNumberAlreadyExists, "PROJECT_NOT_FOUND": projectNotFound, diff --git a/auth/user_mgt_test.go b/auth/user_mgt_test.go index 247296c3..e7b07b54 100644 --- a/auth/user_mgt_test.go +++ b/auth/user_mgt_test.go @@ -1187,6 +1187,7 @@ func TestHTTPErrorWithCode(t *testing.T) { "DUPLICATE_LOCAL_ID": IsUIDAlreadyExists, "EMAIL_EXISTS": IsEmailAlreadyExists, "INSUFFICIENT_PERMISSION": IsInsufficientPermission, + "INVALID_EMAIL": IsInvalidEmail, "PHONE_NUMBER_EXISTS": IsPhoneNumberAlreadyExists, "PROJECT_NOT_FOUND": IsProjectNotFound, }