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"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/mail"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/getprobo/probo/pkg/coredata"
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
@@ -121,7 +121,7 @@ func (s TrustCenterAccessService) Create(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *CreateTrustCenterAccessRequest,
|
req *CreateTrustCenterAccessRequest,
|
||||||
) (*coredata.TrustCenterAccess, error) {
|
) (*coredata.TrustCenterAccess, error) {
|
||||||
if !strings.Contains(req.Email, "@") {
|
if _, err := mail.ParseAddress(req.Email); err != nil {
|
||||||
return nil, fmt.Errorf("invalid email address")
|
return nil, fmt.Errorf("invalid email address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"net/mail"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/getprobo/probo/pkg/coredata"
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
@@ -84,7 +84,7 @@ func (s TrustCenterAccessService) Create(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *CreateTrustCenterAccessRequest,
|
req *CreateTrustCenterAccessRequest,
|
||||||
) (*coredata.TrustCenterAccess, error) {
|
) (*coredata.TrustCenterAccess, error) {
|
||||||
if !strings.Contains(req.Email, "@") {
|
if _, err := mail.ParseAddress(req.Email); err != nil {
|
||||||
return nil, fmt.Errorf("invalid email address")
|
return nil, fmt.Errorf("invalid email address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/getprobo/probo/pkg/coredata"
|
"github.com/getprobo/probo/pkg/coredata"
|
||||||
@@ -636,7 +635,7 @@ func (s Service) InviteUser(
|
|||||||
fullName string,
|
fullName string,
|
||||||
emailAddress string,
|
emailAddress string,
|
||||||
) error {
|
) error {
|
||||||
if !strings.Contains(emailAddress, "@") {
|
if _, err := mail.ParseAddress(emailAddress); err != nil {
|
||||||
return &ErrInvalidEmail{emailAddress}
|
return &ErrInvalidEmail{emailAddress}
|
||||||
}
|
}
|
||||||
if fullName == "" {
|
if fullName == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user