drop redundant id for create requests

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2020-06-17 15:15:18 +02:00
parent f3a1d26d2d
commit 0f938a8b10
3 changed files with 133 additions and 157 deletions
+6 -5
View File
@@ -226,13 +226,14 @@ func (s Service) GetAccount(c context.Context, req *proto.GetAccountRequest, res
// CreateAccount implements the AccountsServiceHandler interface
func (s Service) CreateAccount(c context.Context, req *proto.CreateAccountRequest, res *proto.Account) (err error) {
var id string
if req.Id == "" {
req.Id = uuid.Must(uuid.NewV4()).String()
if req.Account == nil {
return fmt.Errorf("account missing")
}
if req.Account.Id == "" {
req.Account.Id = uuid.Must(uuid.NewV4()).String()
}
// we are always ignoring the id in the account here ... hmm just do away with the extra id property?
req.Account.Id = req.Id
if id, err = cleanupID(req.Id); err != nil {
if id, err = cleanupID(req.Account.Id); err != nil {
return
}
path := filepath.Join(s.Config.Server.AccountsDataPath, "accounts", id)