mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 03:05:14 +00:00
User service: Generate user id if empty (#160)
This commit is contained in:
2
go.mod
2
go.mod
@@ -23,7 +23,7 @@ require (
|
||||
github.com/lib/pq v1.9.0 // indirect
|
||||
github.com/mattheath/base62 v0.0.0-20150408093626-b80cdc656a7a // indirect
|
||||
github.com/mattheath/kala v0.0.0-20171219141654-d6276794bf0e
|
||||
github.com/micro/dev v0.0.0-20201117163752-d3cfc9788dfa
|
||||
github.com/micro/dev v0.0.0-20201117163752-d3cfc9788dfa // indirect
|
||||
github.com/micro/micro/v3 v3.3.1-0.20210611161948-fd9821dd4f52
|
||||
github.com/miekg/dns v1.1.31 // indirect
|
||||
github.com/onsi/ginkgo v1.15.0 // indirect
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
"password": "mySecretPass123"
|
||||
},
|
||||
"response": {
|
||||
"id": "1"
|
||||
}
|
||||
}],
|
||||
"read": [{
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user