prevent users from editing their account jid after successful login
This commit is contained in:
parent
26765a8a0d
commit
0da2f1ed3f
|
@ -535,7 +535,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
|
|||
} else {
|
||||
if (AxolotlService.this.changeAccessMode.compareAndSet(true,false)) {
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done changing access mode");
|
||||
account.setOption(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE,false);
|
||||
account.setOption(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE,false);
|
||||
mXmppConnectionService.databaseBackend.updateAccount(account);
|
||||
}
|
||||
ownPushPending.set(false);
|
||||
|
@ -591,7 +591,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
|
|||
Log.d(Config.LOGTAG, getLogprefix(account) + "publishBundlesIfNeeded called, but PEP is broken. Ignoring... ");
|
||||
return;
|
||||
}
|
||||
this.changeAccessMode.set(account.isOptionSet(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE) && account.getXmppConnection().getFeatures().pepPublishOptions());
|
||||
this.changeAccessMode.set(account.isOptionSet(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE) && account.getXmppConnection().getFeatures().pepPublishOptions());
|
||||
if (this.changeAccessMode.get()) {
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server gained publish-options capabilities. changing access model");
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ public class Account extends AbstractEntity {
|
|||
public static final int OPTION_REGISTER = 2;
|
||||
public static final int OPTION_USECOMPRESSION = 3;
|
||||
public static final int OPTION_MAGIC_CREATE = 4;
|
||||
public static final int OPTION_REQURIES_ACCESS_MODE_CHANGE = 5;
|
||||
public static final int OPTION_REQUIRES_ACCESS_MODE_CHANGE = 5;
|
||||
public static final int OPTION_LOGGED_IN_SUCCESSFULLY = 6;
|
||||
public final HashSet<Pair<String, String>> inProgressDiscoFetches = new HashSet<>();
|
||||
|
||||
public boolean httpUploadAvailable(long filesize) {
|
||||
|
@ -295,12 +296,14 @@ public class Account extends AbstractEntity {
|
|||
return ((options & (1 << option)) != 0);
|
||||
}
|
||||
|
||||
public void setOption(final int option, final boolean value) {
|
||||
public boolean setOption(final int option, final boolean value) {
|
||||
final int before = this.options;
|
||||
if (value) {
|
||||
this.options |= 1 << option;
|
||||
} else {
|
||||
this.options &= ~(1 << option);
|
||||
}
|
||||
return before != this.options;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
|
|
@ -10,7 +10,6 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
import android.os.Environment;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||
|
@ -449,7 +448,8 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
if (oldVersion < 36 && newVersion >= 36) {
|
||||
List<Account> accounts = getAccounts(db);
|
||||
for (Account account : accounts) {
|
||||
account.setOption(Account.OPTION_REQURIES_ACCESS_MODE_CHANGE,true);
|
||||
account.setOption(Account.OPTION_REQUIRES_ACCESS_MODE_CHANGE,true);
|
||||
account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY,false);
|
||||
db.update(Account.TABLENAME, account.getContentValues(), Account.UUID
|
||||
+ "=?", new String[]{account.getUuid()});
|
||||
}
|
||||
|
|
|
@ -300,6 +300,9 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (account.setOption(Account.OPTION_LOGGED_IN_SUCCESSFULLY,true)) {
|
||||
databaseBackend.updateAccount(account);
|
||||
}
|
||||
account.getRoster().clearPresences();
|
||||
mJingleConnectionManager.cancelInTransmission();
|
||||
fetchRosterFromServer(account);
|
||||
|
|
|
@ -843,7 +843,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
} else {
|
||||
this.mAccountJid.getEditableText().append(this.mAccount.getJid().toBareJid().toString());
|
||||
}
|
||||
this.mPassword.setText(this.mAccount.getPassword());
|
||||
this.mPassword.getEditableText().clear();
|
||||
this.mPassword.getEditableText().append(this.mAccount.getPassword());
|
||||
this.mHostname.setText("");
|
||||
this.mHostname.getEditableText().append(this.mAccount.getHostname());
|
||||
this.mPort.setText("");
|
||||
|
@ -852,6 +853,11 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
|
||||
}
|
||||
|
||||
final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY);
|
||||
this.mAccountJid.setEnabled(editable);
|
||||
this.mAccountJid.setFocusable(editable);
|
||||
this.mAccountJid.setFocusableInTouchMode(editable);
|
||||
|
||||
if (!mInitMode) {
|
||||
this.mAvatar.setVisibility(View.VISIBLE);
|
||||
this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));
|
||||
|
|
Loading…
Reference in a new issue