Browse Source

Add Constants

pull/414/head
Sarah Jamie Lewis 4 weeks ago
parent
commit
aa98ef0e5e
  1. 1
      functionality/filesharing/filesharing_functionality.go
  2. 7
      model/constants/errors.go
  3. 6
      peer/cwtch_peer.go

1
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)

7
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"

6
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

Loading…
Cancel
Save