diff --git a/functionality/filesharing/filesharing_functionality.go b/functionality/filesharing/filesharing_functionality.go index 9dab08a..8d76ddf 100644 --- a/functionality/filesharing/filesharing_functionality.go +++ b/functionality/filesharing/filesharing_functionality.go @@ -53,7 +53,6 @@ type OverlayMessage struct { Size uint64 `json:"s"` } - // FileKey is the unique reference to a file offer func (om *OverlayMessage) FileKey() string { return fmt.Sprintf("%s.%s", om.Hash, om.Nonce) diff --git a/model/constants/errors.go b/model/constants/errors.go new file mode 100644 index 0000000..7f41d4b --- /dev/null +++ b/model/constants/errors.go @@ -0,0 +1,7 @@ +package constants + +// InvalidPasswordError is returned when an incorrect password is provided to a function that requires the current active password +const InvalidPasswordError = "invalid_password_error" + +// PasswordsDoNotMatchError is returned when two passwords do not match +const PasswordsDoNotMatchError = "passwords_do_not_match" diff --git a/peer/cwtch_peer.go b/peer/cwtch_peer.go index 5d1e57d..459e4ec 100644 --- a/peer/cwtch_peer.go +++ b/peer/cwtch_peer.go @@ -87,11 +87,11 @@ func (cp *cwtchPeer) ChangePassword(password string, newpassword string, newpass defer cp.mutex.Unlock() db, err := openEncryptedDatabase(cp.storage.ProfileDirectory, password, false) if db == nil || err != nil { - return errors.New("invalid_password") + return errors.New(constants.InvalidPasswordError) } cps, err := NewCwtchProfileStorage(db, cp.storage.ProfileDirectory) if err != nil { - return errors.New("invalid_password") + return errors.New(constants.InvalidPasswordError) } cps.Close() @@ -106,7 +106,7 @@ func (cp *cwtchPeer) ChangePassword(password string, newpassword string, newpass log.Infof("rekeying database...") return cp.storage.Rekey(rekey) } - return errors.New("passwords_do_not_match") + return errors.New(constants.PasswordsDoNotMatchError) } // GenerateProtocolEngine