Add Constants
This commit is contained in:
parent
46f32881b9
commit
aa98ef0e5e
|
@ -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)
|
||||
|
|
|
@ -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"
|
|
@ -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…
Reference in New Issue