Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions auth/user_mgt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions auth/user_mgt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down