package safe

import (
	"github.com/bndw/pick/errors"
)

func (s *Safe) Add(name, username, password string) (*Account, error) {
	if _, exists := s.Accounts[name]; exists {
		account := s.Accounts[name]
		return &account, &errors.AccountExists{}
	}

	account := NewAccount(name, username, password)
	s.Accounts[name] = account

	if err := s.save(); err != nil {
		return nil, err
	}

	return &account, nil
}

package safe

import (
	"github.com/bndw/pick/errors"
)

func (s *Safe) Add(name, username, password string) (*Account, error) {
	if _, exists := s.Accounts[name]; exists {
		return nil, &errors.AccountExists{}
	}

	account := NewAccount(name, username, password)
	s.Accounts[name] = account

	if err := s.save(); err != nil {
		return nil, err
	}

	return &account, nil
}

--- 
+++ 
@@ -6,7 +6,8 @@
 
 func (s *Safe) Add(name, username, password string) (*Account, error) {
 	if _, exists := s.Accounts[name]; exists {
-		return nil, &errors.AccountExists{}
+		account := s.Accounts[name]
+		return &account, &errors.AccountExists{}
 	}
 
 	account := NewAccount(name, username, password)
Fix issue when generating a new password for an already existing account.

Issue was introduced in 86787659fd4a75bc2b1a1e02135afddd649a4899
