diff --git a/pkg/probo/trust_center_access_service.go b/pkg/probo/trust_center_access_service.go index 47538dea6..9c65bfc67 100644 --- a/pkg/probo/trust_center_access_service.go +++ b/pkg/probo/trust_center_access_service.go @@ -18,8 +18,8 @@ import ( "context" "errors" "fmt" + "net/mail" "net/url" - "strings" "time" "github.com/getprobo/probo/pkg/coredata" @@ -121,7 +121,7 @@ func (s TrustCenterAccessService) Create( ctx context.Context, req *CreateTrustCenterAccessRequest, ) (*coredata.TrustCenterAccess, error) { - if !strings.Contains(req.Email, "@") { + if _, err := mail.ParseAddress(req.Email); err != nil { return nil, fmt.Errorf("invalid email address") } diff --git a/pkg/trust/trust_center_access_service.go b/pkg/trust/trust_center_access_service.go index acfadf947..8af922f1f 100644 --- a/pkg/trust/trust_center_access_service.go +++ b/pkg/trust/trust_center_access_service.go @@ -18,7 +18,7 @@ import ( "context" "errors" "fmt" - "strings" + "net/mail" "time" "github.com/getprobo/probo/pkg/coredata" @@ -84,7 +84,7 @@ func (s TrustCenterAccessService) Create( ctx context.Context, req *CreateTrustCenterAccessRequest, ) (*coredata.TrustCenterAccess, error) { - if !strings.Contains(req.Email, "@") { + if _, err := mail.ParseAddress(req.Email); err != nil { return nil, fmt.Errorf("invalid email address") } diff --git a/pkg/usrmgr/usrmgr.go b/pkg/usrmgr/usrmgr.go index 0be1173ef..bc43f6355 100644 --- a/pkg/usrmgr/usrmgr.go +++ b/pkg/usrmgr/usrmgr.go @@ -20,7 +20,6 @@ import ( "fmt" "net/mail" "net/url" - "strings" "time" "github.com/getprobo/probo/pkg/coredata" @@ -636,7 +635,7 @@ func (s Service) InviteUser( fullName string, emailAddress string, ) error { - if !strings.Contains(emailAddress, "@") { + if _, err := mail.ParseAddress(emailAddress); err != nil { return &ErrInvalidEmail{emailAddress} } if fullName == "" {