mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-07-23 06:50:55 -04:00
accountService.changePassword() requires old and new password
This commit is contained in:
parent
6719324d9e
commit
5a7ec350ca
2 changed files with 19 additions and 7 deletions
|
@ -419,9 +419,18 @@ test("Can manage an account (CI)", async () => {
|
||||||
assert(await user3.accountExists());
|
assert(await user3.accountExists());
|
||||||
assert(await user3.isAccountOpen());
|
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
|
// change password
|
||||||
password = "newPassword";
|
const newPassword = "newPassword";
|
||||||
await user3.changePassword(password);
|
await user3.changePassword(password, newPassword);
|
||||||
|
password = newPassword;
|
||||||
assert(await user3.accountExists());
|
assert(await user3.accountExists());
|
||||||
assert(await user3.isAccountOpen());
|
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);
|
testConnection(connection!, TestConfig.monerod2.url, OnlineStatus.ONLINE, AuthenticationStatus.AUTHENTICATED, 1);
|
||||||
|
|
||||||
// change account password
|
// change account password
|
||||||
const password = "newPassword";
|
const newPassword = "newPassword";
|
||||||
await user3.changePassword("newPassword");
|
await user3.changePassword(TestConfig.defaultHavenod.accountPassword, newPassword);
|
||||||
|
|
||||||
// restart user3
|
// restart user3
|
||||||
const appName = user3.getAppName();
|
const appName = user3.getAppName();
|
||||||
await releaseHavenoProcess(user3);
|
await releaseHavenoProcess(user3);
|
||||||
user3 = await initHaveno({appName: appName, accountPassword: password});
|
user3 = await initHaveno({appName: appName, accountPassword: newPassword});
|
||||||
|
|
||||||
// connection is restored, online, and authenticated
|
// connection is restored, online, and authenticated
|
||||||
connection = await user3.getMoneroConnection();
|
connection = await user3.getMoneroConnection();
|
||||||
|
|
|
@ -301,9 +301,12 @@ export default class HavenoClient {
|
||||||
*
|
*
|
||||||
* @param {string} password - the new account password
|
* @param {string} password - the new account password
|
||||||
*/
|
*/
|
||||||
async changePassword(password: string): Promise<void> {
|
async changePassword(oldPassword: string, newPassword: string): Promise<void> {
|
||||||
try {
|
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) {
|
} catch (e: any) {
|
||||||
throw new HavenoError(e.message, e.code);
|
throw new HavenoError(e.message, e.code);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue