Merge pull request 'fix: use ValidateEmail as binding across web forms' (#5158) from solomonv/consolidate-email-validation into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5158
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
Gusted 2024-10-21 14:31:32 +00:00
commit f298bf125a
24 changed files with 281 additions and 221 deletions

View file

@ -717,11 +717,11 @@ func createUser(ctx context.Context, u *User, createdByAdmin bool, overwriteDefa
}
if createdByAdmin {
if err := ValidateEmailForAdmin(u.Email); err != nil {
if err := validation.ValidateEmailForAdmin(u.Email); err != nil {
return err
}
} else {
if err := ValidateEmail(u.Email); err != nil {
if err := validation.ValidateEmail(u.Email); err != nil {
return err
}
}
@ -885,7 +885,7 @@ func (u User) Validate() []string {
if err := ValidateUser(&u); err != nil {
result = append(result, err.Error())
}
if err := ValidateEmail(u.Email); err != nil {
if err := validation.ValidateEmail(u.Email); err != nil {
result = append(result, err.Error())
}
return result