mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 11:39:29 +00: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() {
|
||||
|
|
|
@ -145,7 +145,7 @@ public class GrpcAccountService extends AccountImplBase {
|
|||
@Override
|
||||
public void changePassword(ChangePasswordRequest req, StreamObserver<ChangePasswordReply> responseObserver) {
|
||||
try {
|
||||
coreApi.changePassword(req.getPassword());
|
||||
coreApi.changePassword(req.getOldPassword(), req.getNewPassword());
|
||||
var reply = ChangePasswordReply.newBuilder().build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
|
|
|
@ -119,7 +119,8 @@ message IsAppInitializedReply {
|
|||
}
|
||||
|
||||
message ChangePasswordRequest {
|
||||
string password = 1;
|
||||
string old_password = 1;
|
||||
string new_password = 2;
|
||||
}
|
||||
|
||||
message ChangePasswordReply {
|
||||
|
|
Loading…
Reference in a new issue