changePassword #414

Merged
sarah merged 4 commits from changePassword into master 2021-12-19 01:12:25 +00:00
3 changed files with 10 additions and 4 deletions
Showing only changes of commit aa98ef0e5e - Show all commits

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