mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-01-11 23:39:49 -05:00
accountService.changePassword() requires old and new password
This commit is contained in:
parent
6719324d9e
commit
5a7ec350ca
@ -419,9 +419,18 @@ test("Can manage an account (CI)", async () => {
|
||||
assert(await user3.accountExists());
|
||||
assert(await user3.isAccountOpen());
|
||||
|
||||
// try changing incorrect password
|
||||
try {
|
||||
await user3.changePassword("wrongPassword", "abc123");
|
||||
throw new Error("Should have failed changing wrong password");
|
||||
} catch (err: any) {
|
||||
assert.equal(err.message, "Incorrect password");
|
||||
}
|
||||
|
||||
// change password
|
||||
password = "newPassword";
|
||||
await user3.changePassword(password);
|
||||
const newPassword = "newPassword";
|
||||
await user3.changePassword(password, newPassword);
|
||||
password = newPassword;
|
||||
assert(await user3.accountExists());
|
||||
assert(await user3.isAccountOpen());
|
||||
|
||||
@ -554,13 +563,13 @@ test("Can manage Monero daemon connections (CI)", async () => {
|
||||
testConnection(connection!, TestConfig.monerod2.url, OnlineStatus.ONLINE, AuthenticationStatus.AUTHENTICATED, 1);
|
||||
|
||||
// change account password
|
||||
const password = "newPassword";
|
||||
await user3.changePassword("newPassword");
|
||||
const newPassword = "newPassword";
|
||||
await user3.changePassword(TestConfig.defaultHavenod.accountPassword, newPassword);
|
||||
|
||||
// restart user3
|
||||
const appName = user3.getAppName();
|
||||
await releaseHavenoProcess(user3);
|
||||
user3 = await initHaveno({appName: appName, accountPassword: password});
|
||||
user3 = await initHaveno({appName: appName, accountPassword: newPassword});
|
||||
|
||||
// connection is restored, online, and authenticated
|
||||
connection = await user3.getMoneroConnection();
|
||||
|
@ -301,9 +301,12 @@ export default class HavenoClient {
|
||||
*
|
||||
* @param {string} password - the new account password
|
||||
*/
|
||||
async changePassword(password: string): Promise<void> {
|
||||
async changePassword(oldPassword: string, newPassword: string): Promise<void> {
|
||||
try {
|
||||
await this._accountClient.changePassword(new ChangePasswordRequest().setPassword(password), {password: this._password});
|
||||
const request = new ChangePasswordRequest()
|
||||
.setOldPassword(oldPassword)
|
||||
.setNewPassword(newPassword);
|
||||
await this._accountClient.changePassword(request, {password: this._password});
|
||||
} catch (e: any) {
|
||||
throw new HavenoError(e.message, e.code);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user