From a673135c3fb0addc10e7cc727e8d050d63fd8d30 Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Wed, 3 Sep 2025 10:26:09 +0200 Subject: [PATCH] Use mail parse address everywhere Signed-off-by: Sacha Al Himdani --- pkg/probo/trust_center_access_service.go | 4 ++-- pkg/trust/trust_center_access_service.go | 4 ++-- pkg/usrmgr/usrmgr.go | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) 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 == "" {