User service: Generate user id if empty (#160)

This commit is contained in:
Janos Dobronszki
2021-06-15 12:39:07 +01:00
committed by GitHub
parent fe0f4f4169
commit b73dab3345
3 changed files with 5 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import (
"strings"
"time"
"github.com/google/uuid"
"github.com/micro/micro/v3/service/errors"
db "github.com/micro/services/db/proto"
"github.com/micro/services/user/domain"
@@ -54,7 +55,9 @@ func (s *User) Create(ctx context.Context, req *pb.CreateRequest, rsp *pb.Create
return errors.InternalServerError("user.Create", err.Error())
}
pp := base64.StdEncoding.EncodeToString(h)
if req.Id == "" {
req.Id = uuid.New().String()
}
return s.domain.Create(ctx, &pb.Account{
Id: req.Id,
Username: strings.ToLower(req.Username),