Use mail parse address everywhere
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
@@ -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 == "" {
|
||||
|
||||
Reference in New Issue
Block a user