mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
fix: use ValidateEmail as binding across web forms
This commit is contained in:
parent
df907ec7f9
commit
471567b3ba
24 changed files with 281 additions and 221 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/validation"
|
||||
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
@ -31,7 +32,7 @@ func iterateUserAccounts(ctx context.Context, each func(*user.User) error) error
|
|||
func checkUserEmail(ctx context.Context, logger log.Logger, _ bool) error {
|
||||
// We could use quirky SQL to get all users that start without a [a-zA-Z0-9], but that would mean
|
||||
// DB provider-specific SQL and only works _now_. So instead we iterate through all user accounts
|
||||
// and use the user.ValidateEmail function to be future-proof.
|
||||
// and use the validation.ValidateEmail function to be future-proof.
|
||||
var invalidUserCount int64
|
||||
if err := iterateUserAccounts(ctx, func(u *user.User) error {
|
||||
// Only check for users, skip
|
||||
|
@ -39,7 +40,7 @@ func checkUserEmail(ctx context.Context, logger log.Logger, _ bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := user.ValidateEmail(u.Email); err != nil {
|
||||
if err := validation.ValidateEmail(u.Email); err != nil {
|
||||
invalidUserCount++
|
||||
logger.Warn("User[id=%d name=%q] have not a valid e-mail: %v", u.ID, u.Name, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue