mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-12 09:51:25 +01:00
add email check
This commit is contained in:
parent
57081792de
commit
867b4bc352
@ -17,7 +17,7 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
// "regexp"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/vmware/harbor/models"
|
||||
@ -74,8 +74,13 @@ func validate(user models.User) error {
|
||||
return errors.New("Username already exists.")
|
||||
}
|
||||
|
||||
if exist, _ := UserExists(models.User{Email: user.Email}, "email"); len(user.Email) > 0 && exist {
|
||||
return errors.New("Email already exists.")
|
||||
if len(user.Email) > 0 {
|
||||
if m, _ := regexp.MatchString(`^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$`, user.Email); !m {
|
||||
return errors.New("Email with illegal format.")
|
||||
}
|
||||
if exist, _ := UserExists(models.User{Email: user.Email}, "email"); exist {
|
||||
return errors.New("Email already exists.")
|
||||
}
|
||||
}
|
||||
|
||||
if isIllegalLength(user.Realname, 0, 20) {
|
||||
|
Loading…
Reference in New Issue
Block a user