You've already forked openaccounting-server
mirror of
https://github.com/openaccounting/oa-server.git
synced 2025-12-09 00:50:59 +13:00
validate email address
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/sendgrid/sendgrid-go"
|
||||
"github.com/sendgrid/sendgrid-go/helpers/mail"
|
||||
"log"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type UserInterface interface {
|
||||
@@ -34,6 +35,12 @@ func (model *Model) CreateUser(user *types.User) error {
|
||||
return errors.New("email required")
|
||||
}
|
||||
|
||||
re := regexp.MustCompile(".+@.+\\..+")
|
||||
|
||||
if re.FindString(user.Email) == "" {
|
||||
return errors.New("invalid email address")
|
||||
}
|
||||
|
||||
if user.Password == "" {
|
||||
return errors.New("password required")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user