Change identity password on changing account password for same tld

This commit is contained in:
M66B 2019-09-01 19:42:52 +02:00
parent 72214f2884
commit c89dd5a979
2 changed files with 19 additions and 0 deletions

View File

@ -930,6 +930,17 @@ public class FragmentAccount extends FragmentBase {
try {
db.beginTransaction();
if (account != null && !account.password.equals(password)) {
List<EntityIdentity> identities = db.identity().getIdentities(account.id);
for (EntityIdentity identity : identities)
if (identity.password.equals(account.password) &&
Helper.getTld(identity.host).equals(Helper.getTld(account.host))) {
Log.i("Changing identity password host=" + identity.host);
identity.password = password;
db.identity().updateIdentity(identity);
}
}
boolean update = (account != null);
if (account == null)
account = new EntityAccount();

View File

@ -871,6 +871,14 @@ public class Helper {
return true;
}
static String getTld(String host) {
String[] h = host.split("\\.");
if (h.length >= 2)
return h[h.length - 2] + "." + h[h.length - 1];
else
return host;
}
static int getSize(Bundle bundle) {
Parcel p = Parcel.obtain();
bundle.writeToParcel(p, 0);