mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-13 08:55:31 -04:00
accountService.changePassword() requires old and new password
This commit is contained in:
parent
86511b4e21
commit
55650c495b
4 changed files with 13 additions and 9 deletions
|
@ -35,6 +35,9 @@ import java.util.List;
|
|||
import java.util.function.Consumer;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -111,13 +114,13 @@ public class CoreAccountService {
|
|||
}
|
||||
}
|
||||
|
||||
public void changePassword(String password) {
|
||||
public void changePassword(String oldPassword, String newPassword) {
|
||||
if (!isAccountOpen()) throw new IllegalStateException("Cannot change password on unopened account");
|
||||
String oldPassword = this.password;
|
||||
keyStorage.saveKeyRing(keyRing, oldPassword, password);
|
||||
this.password = password;
|
||||
if (!StringUtils.equals(this.password, oldPassword)) throw new IllegalStateException("Incorrect password");
|
||||
keyStorage.saveKeyRing(keyRing, oldPassword, newPassword);
|
||||
this.password = newPassword;
|
||||
synchronized (listeners) {
|
||||
for (AccountServiceListener listener : listeners) listener.onPasswordChanged(oldPassword, password);
|
||||
for (AccountServiceListener listener : listeners) listener.onPasswordChanged(oldPassword, newPassword);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -169,8 +169,8 @@ public class CoreApi {
|
|||
return appStartupState.isApplicationFullyInitialized();
|
||||
}
|
||||
|
||||
public void changePassword(String password) {
|
||||
coreAccountService.changePassword(password);
|
||||
public void changePassword(String oldPassword, String newPassword) {
|
||||
coreAccountService.changePassword(oldPassword, newPassword);
|
||||
}
|
||||
|
||||
public void closeAccount() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue