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 {
|
} else {
|
||||||
if (AxolotlService.this.changeAccessMode.compareAndSet(true,false)) {
|
if (AxolotlService.this.changeAccessMode.compareAndSet(true,false)) {
|
||||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done changing access mode");
|
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);
|
mXmppConnectionService.databaseBackend.updateAccount(account);
|
||||||
}
|
}
|
||||||
ownPushPending.set(false);
|
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... ");
|
Log.d(Config.LOGTAG, getLogprefix(account) + "publishBundlesIfNeeded called, but PEP is broken. Ignoring... ");
|
||||||
return;
|
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()) {
|
if (this.changeAccessMode.get()) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": server gained publish-options capabilities. changing access model");
|
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_REGISTER = 2;
|
||||||
public static final int OPTION_USECOMPRESSION = 3;
|
public static final int OPTION_USECOMPRESSION = 3;
|
||||||
public static final int OPTION_MAGIC_CREATE = 4;
|
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 final HashSet<Pair<String, String>> inProgressDiscoFetches = new HashSet<>();
|
||||||
|
|
||||||
public boolean httpUploadAvailable(long filesize) {
|
public boolean httpUploadAvailable(long filesize) {
|
||||||
|
@ -295,12 +296,14 @@ public class Account extends AbstractEntity {
|
||||||
return ((options & (1 << option)) != 0);
|
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) {
|
if (value) {
|
||||||
this.options |= 1 << option;
|
this.options |= 1 << option;
|
||||||
} else {
|
} else {
|
||||||
this.options &= ~(1 << option);
|
this.options &= ~(1 << option);
|
||||||
}
|
}
|
||||||
|
return before != this.options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||||
|
@ -449,7 +448,8 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
||||||
if (oldVersion < 36 && newVersion >= 36) {
|
if (oldVersion < 36 && newVersion >= 36) {
|
||||||
List<Account> accounts = getAccounts(db);
|
List<Account> accounts = getAccounts(db);
|
||||||
for (Account account : accounts) {
|
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
|
db.update(Account.TABLENAME, account.getContentValues(), Account.UUID
|
||||||
+ "=?", new String[]{account.getUuid()});
|
+ "=?", 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();
|
account.getRoster().clearPresences();
|
||||||
mJingleConnectionManager.cancelInTransmission();
|
mJingleConnectionManager.cancelInTransmission();
|
||||||
fetchRosterFromServer(account);
|
fetchRosterFromServer(account);
|
||||||
|
|
|
@ -843,7 +843,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
} else {
|
} else {
|
||||||
this.mAccountJid.getEditableText().append(this.mAccount.getJid().toBareJid().toString());
|
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.setText("");
|
||||||
this.mHostname.getEditableText().append(this.mAccount.getHostname());
|
this.mHostname.getEditableText().append(this.mAccount.getHostname());
|
||||||
this.mPort.setText("");
|
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) {
|
if (!mInitMode) {
|
||||||
this.mAvatar.setVisibility(View.VISIBLE);
|
this.mAvatar.setVisibility(View.VISIBLE);
|
||||||
this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));
|
this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72)));
|
||||||
|
|
Loading…
Reference in a new issue