Skip to content

Commit

Permalink
fixed bug and implemented feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
faboweb authored and ebuchman committed Dec 7, 2017
1 parent 23e464d commit 3986e18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions client/rest/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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}
Expand Down
10 changes: 9 additions & 1 deletion client/rest/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down

0 comments on commit 3986e18

Please sign in to comment.