Add Constants
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Sarah Jamie Lewis 2021-12-18 16:51:36 -08:00
parent 46f32881b9
commit aa98ef0e5e
3 changed files with 10 additions and 4 deletions

View File

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

View File

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

View File

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