我有一个名为SettingsActivity的活动。此活动用于更改登录密码。
我在其他方面遇到问题。当我单击“提交”按钮时,它会在更改密码的同时吐出“不正确的旧密码”和“已更改登录密码”。
LoginRef.child(currentUserId).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
String oldpassword = dataSnapshot.child("password").getValue().toString();
String oldPassword = LoginOldPassword.getText().toString();
String newPassword = LoginNewPassword.getText().toString();
String confirmNewPassword = LoginConfirmNewPassword.getText().toString();
if(!newPassword.equals(confirmNewPassword)){
Toast.makeText(SettingsActivity.this,"Passwords Not Matching!",Toast.LENGTH_SHORT).show();
}
else if(!oldPassword.equals(oldpassword)){
Toast.makeText(SettingsActivity.this,"Incorrect Old Password!",Toast.LENGTH_SHORT).show();
}
else if(newPassword.equals(oldPassword)){
Toast.makeText(SettingsActivity.this,"Old Password and New Password Cannot Be Same!",Toast.LENGTH_SHORT).show();
}
else {
HashMap loginmap = new HashMap();
loginmap.put("password",newPassword);
LoginRef.child(currentUserId).updateChildren(loginmap).addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
Toast.makeText(SettingsActivity.this,"Login Password Changed",Toast.LENGTH_SHORT).show();
}
});
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
我不希望在烘烤“登录密码已更改”的同时烘烤“不正确的旧密码”。