Skip to content

Instantly share code, notes, and snippets.

@dimroc
Created February 9, 2019 15:47
Show Gist options
  • Save dimroc/c506d09c8dc6cb491c0b0f0309e0e27a to your computer and use it in GitHub Desktop.
Save dimroc/c506d09c8dc6cb491c0b0f0309e0e27a to your computer and use it in GitHub Desktop.
diff --git a/web/keys_controller.go b/web/keys_controller.go
index c76ba719..091ad270 100644
--- a/web/keys_controller.go
+++ b/web/keys_controller.go
@@ -18,16 +18,22 @@ type KeysController struct {
// "<application>/keys"
func (c *KeysController) Create(ctx *gin.Context) {
request := models.CreateKeyRequest{}
+
// TODO: Change CreateKeyRequest to only have one password
// or validate that they are the same.
+ // TODO: Does this add the key to the keystore at run time?
+ // I believe we need to invoke store,KeyStore.Unlock after NewAccount
+ // to update the internal KeyStore cache.
+
+ store := c.App.GetStore()
if err := ctx.ShouldBindJSON(&request); err != nil {
publicError(ctx, 422, err)
- } else if err := c.App.GetStore().KeyStore.Unlock(request.CurrentPassword); err != nil {
+ } else if err := store.KeyStore.Unlock(request.CurrentPassword); err != nil {
publicError(ctx, 401, err)
- } else if account, err := c.App.GetStore().KeyStore.NewAccount(request.NewAccountPassword); err != nil {
+ } else if account, err := store.KeyStore.NewAccount(request.NewAccountPassword); err != nil {
ctx.AbortWithError(500, err)
- } else if err := c.App.GetStore().SyncDiskKeyStoreToDb(); err != nil {
+ } else if err := store.SyncDiskKeyStoreToDb(); err != nil { // redo all this joint
ctx.AbortWithError(500, err)
} else if doc, err := jsonapi.Marshal(&presenters.NewAccount{&account}); err != nil {
ctx.AbortWithError(500, err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment