From 3986e186e1dda1244cffbf5ba24726c07de24263 Mon Sep 17 00:00:00 2001 From: Fabian Date: Wed, 6 Dec 2017 19:06:12 +0100 Subject: [PATCH] fixed bug and implemented feedback --- client/rest/handlers.go | 10 +++++----- client/rest/types.go | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/client/rest/handlers.go b/client/rest/handlers.go index 0b847165a6ef..99127f1c96b6 100644 --- a/client/rest/handlers.go +++ b/client/rest/handlers.go @@ -127,21 +127,21 @@ func (k *Keys) DeleteKey(w http.ResponseWriter, r *http.Request) { } func (k *Keys) RecoverKey(w http.ResponseWriter, r *http.Request) { - ckReq := &RecoverKeyRequest{ + rkReq := &RecoverKeyRequest{ Algo: k.algo, } - if err := common.ParseRequestAndValidateJSON(r, ckReq); err != nil { + if err := common.ParseRequestAndValidateJSON(r, rkReq); err != nil { common.WriteError(w, err) return } - key, err := k.manager.Recover(ckReq.Name, ckReq.Passphrase, ckReq.Seed) + key, err := k.manager.Recover(rkReq.Name, rkReq.Passphrase, rkReq.Seed) if err != nil { common.WriteError(w, err) return } - res := &CreateKeyResponse{Key: key, Seed: ckReq.Seed} + res := &CreateKeyResponse{Key: key, Seed: rkReq.Seed} common.WriteSuccess(w, res) } @@ -187,7 +187,7 @@ func RegisterPostTx(r *mux.Router) error { // RegisterAllCRUD is a convenience method to register all // CRUD for keys to allow access by methods and routes: // POST: /keys -// POST: /keys/recover +// POST: /keys/recover // GET: /keys // GET: /keys/{name} // POST, PUT: /keys/{name} diff --git a/client/rest/types.go b/client/rest/types.go index 91ffe52b3ebc..529fcbe20962 100644 --- a/client/rest/types.go +++ b/client/rest/types.go @@ -9,7 +9,6 @@ import ( type CreateKeyRequest struct { Name string `json:"name,omitempty" validate:"required,min=3,printascii"` Passphrase string `json:"password,omitempty" validate:"required,min=10"` - Seed string `json:"seed_phrase,omitempty" validate:"min=23"` // Algo is the requested algorithm to create the key Algo string `json:"algo,omitempty"` @@ -26,6 +25,15 @@ type UpdateKeyRequest struct { NewPass string `json:"new_passphrase,omitempty" validate:"required,min=10"` } +type RecoverKeyRequest struct { + Name string `json:"name,omitempty" validate:"required,min=3,printascii"` + Passphrase string `json:"password,omitempty" validate:"required,min=10"` + Seed string `json:"seed_phrase,omitempty" validate:"required,min=23"` + + // Algo is the requested algorithm to create the key + Algo string `json:"algo,omitempty"` +} + type SignRequest struct { Name string `json:"name,omitempty" validate:"required,min=3,printascii"` Password string `json:"password,omitempty" validate:"required,min=10"`