diff --git a/internal/api/v1beta1/user.go b/internal/api/v1beta1/user.go index cc4d71354..3453b146a 100644 --- a/internal/api/v1beta1/user.go +++ b/internal/api/v1beta1/user.go @@ -103,9 +103,14 @@ func (h Handler) CreateUser(ctx context.Context, request *shieldv1beta1.CreateUs return nil, grpcBadBodyError } + currentUserEmail, ok := user.GetEmailFromContext(ctx) + if !ok { + return nil, grpcUnauthenticated + } + email := strings.TrimSpace(request.GetBody().GetEmail()) if email == "" { - return nil, grpcBadBodyError + email = currentUserEmail } if !isValidEmail(email) { return nil, user.ErrInvalidEmail