Skip to content

Commit 17d8615

Browse files
shogo82148hiranya911
authored andcommitted
add auth.IsInvalidEmail function, fixes #295 (#299)
1 parent 4c9078c commit 17d8615

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

auth/user_mgt.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ const (
320320
idTokenRevoked = "id-token-revoked"
321321
insufficientPermission = "insufficient-permission"
322322
invalidDynamicLinkDomain = "invalid-dynamic-link-domain"
323+
invalidEmail = "invalid-email"
323324
phoneNumberAlreadyExists = "phone-number-already-exists"
324325
projectNotFound = "project-not-found"
325326
sessionCookieRevoked = "session-cookie-revoked"
@@ -354,6 +355,11 @@ func IsInvalidDynamicLinkDomain(err error) bool {
354355
return internal.HasErrorCode(err, invalidDynamicLinkDomain)
355356
}
356357

358+
// IsInvalidEmail checks if the given error was due to an invalid email.
359+
func IsInvalidEmail(err error) bool {
360+
return internal.HasErrorCode(err, invalidEmail)
361+
}
362+
357363
// IsPhoneNumberAlreadyExists checks if the given error was due to a duplicate phone number.
358364
func IsPhoneNumberAlreadyExists(err error) bool {
359365
return internal.HasErrorCode(err, phoneNumberAlreadyExists)
@@ -396,6 +402,7 @@ var serverError = map[string]string{
396402
"EMAIL_EXISTS": emailAlreadyExists,
397403
"INSUFFICIENT_PERMISSION": insufficientPermission,
398404
"INVALID_DYNAMIC_LINK_DOMAIN": invalidDynamicLinkDomain,
405+
"INVALID_EMAIL": invalidEmail,
399406
"PERMISSION_DENIED": insufficientPermission,
400407
"PHONE_NUMBER_EXISTS": phoneNumberAlreadyExists,
401408
"PROJECT_NOT_FOUND": projectNotFound,

auth/user_mgt_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ func TestHTTPErrorWithCode(t *testing.T) {
11871187
"DUPLICATE_LOCAL_ID": IsUIDAlreadyExists,
11881188
"EMAIL_EXISTS": IsEmailAlreadyExists,
11891189
"INSUFFICIENT_PERMISSION": IsInsufficientPermission,
1190+
"INVALID_EMAIL": IsInvalidEmail,
11901191
"PHONE_NUMBER_EXISTS": IsPhoneNumberAlreadyExists,
11911192
"PROJECT_NOT_FOUND": IsProjectNotFound,
11921193
}

0 commit comments

Comments
 (0)