aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-04-10 14:12:38 +0800
committerGitHub <noreply@github.com>2021-04-10 07:12:38 +0100
commite375cbfd464e12a704c3c1325315a0381ab877a7 (patch)
tree93d0769ac68625a5a365a821b1a4bf9aa3470bac /models
parent9a0858cecf3518c9c5808bc2aeaa99278fd86cd0 (diff)
downloadgitea-e375cbfd464e12a704c3c1325315a0381ab877a7.tar.gz
gitea-e375cbfd464e12a704c3c1325315a0381ab877a7.zip
rsponse 404 when delete not exist email (#15383)
fix #15357 Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'models')
-rw-r--r--models/error.go15
-rw-r--r--models/user_mail.go6
2 files changed, 16 insertions, 5 deletions
diff --git a/models/error.go b/models/error.go
index 6e110f94d7..48cba57a81 100644
--- a/models/error.go
+++ b/models/error.go
@@ -222,6 +222,21 @@ func (err ErrEmailInvalid) Error() string {
return fmt.Sprintf("e-mail invalid [email: %s]", err.Email)
}
+// ErrEmailAddressNotExist email address not exist
+type ErrEmailAddressNotExist struct {
+ Email string
+}
+
+// IsErrEmailAddressNotExist checks if an error is an ErrEmailAddressNotExist
+func IsErrEmailAddressNotExist(err error) bool {
+ _, ok := err.(ErrEmailAddressNotExist)
+ return ok
+}
+
+func (err ErrEmailAddressNotExist) Error() string {
+ return fmt.Sprintf("Email address does not exist [email: %s]", err.Email)
+}
+
// ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.
type ErrOpenIDAlreadyUsed struct {
OpenID string
diff --git a/models/user_mail.go b/models/user_mail.go
index f3e4fe984f..1bdd6a423c 100644
--- a/models/user_mail.go
+++ b/models/user_mail.go
@@ -6,7 +6,6 @@
package models
import (
- "errors"
"fmt"
"net/mail"
"strings"
@@ -18,9 +17,6 @@ import (
"xorm.io/builder"
)
-// ErrEmailAddressNotExist email address not exist
-var ErrEmailAddressNotExist = errors.New("Email address does not exist")
-
// EmailAddress is the list of all email addresses of a user. Can contain the
// primary email address, but is not obligatory.
type EmailAddress struct {
@@ -243,7 +239,7 @@ func DeleteEmailAddress(email *EmailAddress) (err error) {
if err != nil {
return err
} else if deleted != 1 {
- return ErrEmailAddressNotExist
+ return ErrEmailAddressNotExist{Email: email.Email}
}
return nil
}