change

Changes an account's password. The current credentials are checked with auth() first, so a successful change also leaves the account logged in.

Parameter

Description

username

The account's username.

password

The current password.

newPassword

The new password.

callback

Optional function that receives null on success, or an error message.

The account's keys don't change, only the password that protects them, so its data and public key stay the same. Without a callback, errors are logged to the console.

Examples

user.change("alice", "a strong password", "an even stronger one", err => {
  if (err) return console.error(err)
  console.log("password changed")
})

// Without a callback, errors are logged to the console.
user.change("alice", "an even stronger one", "the strongest yet")