mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +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 java.util.function.Consumer;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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");
|
if (!isAccountOpen()) throw new IllegalStateException("Cannot change password on unopened account");
|
||||||
String oldPassword = this.password;
|
if (!StringUtils.equals(this.password, oldPassword)) throw new IllegalStateException("Incorrect password");
|
||||||
keyStorage.saveKeyRing(keyRing, oldPassword, password);
|
keyStorage.saveKeyRing(keyRing, oldPassword, newPassword);
|
||||||
this.password = password;
|
this.password = newPassword;
|
||||||
synchronized (listeners) {
|
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();
|
return appStartupState.isApplicationFullyInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePassword(String password) {
|
public void changePassword(String oldPassword, String newPassword) {
|
||||||
coreAccountService.changePassword(password);
|
coreAccountService.changePassword(oldPassword, newPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeAccount() {
|
public void closeAccount() {
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class GrpcAccountService extends AccountImplBase {
|
||||||
@Override
|
@Override
|
||||||
public void changePassword(ChangePasswordRequest req, StreamObserver<ChangePasswordReply> responseObserver) {
|
public void changePassword(ChangePasswordRequest req, StreamObserver<ChangePasswordReply> responseObserver) {
|
||||||
try {
|
try {
|
||||||
coreApi.changePassword(req.getPassword());
|
coreApi.changePassword(req.getOldPassword(), req.getNewPassword());
|
||||||
var reply = ChangePasswordReply.newBuilder().build();
|
var reply = ChangePasswordReply.newBuilder().build();
|
||||||
responseObserver.onNext(reply);
|
responseObserver.onNext(reply);
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
|
|
|
@ -119,7 +119,8 @@ message IsAppInitializedReply {
|
||||||
}
|
}
|
||||||
|
|
||||||
message ChangePasswordRequest {
|
message ChangePasswordRequest {
|
||||||
string password = 1;
|
string old_password = 1;
|
||||||
|
string new_password = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ChangePasswordReply {
|
message ChangePasswordReply {
|
||||||
|
|
Loading…
Reference in a new issue