mirror of https://github.com/M66B/FairEmail.git
Simplify changing password
This commit is contained in:
parent
da4e7cf9da
commit
6ed4408731
|
@ -79,55 +79,10 @@ public class ActivityError extends ActivityBase {
|
||||||
tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
|
tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
tvMessage.setText(message);
|
tvMessage.setText(message);
|
||||||
|
|
||||||
boolean outlook = (auth_type == ServiceAuthenticator.AUTH_TYPE_OAUTH &&
|
btnPassword.setVisibility(account < 0 ? View.GONE : View.VISIBLE);
|
||||||
("office365".equals(provider) || "outlook".equals(provider)));
|
|
||||||
btnPassword.setVisibility(outlook && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
|
||||||
btnPassword.setOnClickListener(new View.OnClickListener() {
|
btnPassword.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putLong("id", account);
|
|
||||||
|
|
||||||
new SimpleTask<Void>() {
|
|
||||||
@Override
|
|
||||||
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
||||||
long id = args.getLong("id");
|
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
|
||||||
try {
|
|
||||||
db.beginTransaction();
|
|
||||||
|
|
||||||
EntityAccount account = db.account().getAccount(id);
|
|
||||||
if (account == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (account.auth_type == ServiceAuthenticator.AUTH_TYPE_OAUTH &&
|
|
||||||
("office365".equals(account.provider) ||
|
|
||||||
"outlook".equals(account.provider))) {
|
|
||||||
account.auth_type = ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
|
||||||
account.password = "";
|
|
||||||
db.account().updateAccount(account);
|
|
||||||
|
|
||||||
List<EntityIdentity> identities = db.identity().getIdentities(account.id);
|
|
||||||
if (identities != null)
|
|
||||||
for (EntityIdentity identity : identities)
|
|
||||||
if (identity.auth_type == ServiceAuthenticator.AUTH_TYPE_OAUTH) {
|
|
||||||
identity.auth_type = ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
|
||||||
identity.password = "";
|
|
||||||
db.identity().updateIdentity(identity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onExecuted(Bundle args, Void data) {
|
|
||||||
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
|
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||||
.putExtra("target", "accounts")
|
.putExtra("target", "accounts")
|
||||||
|
@ -135,13 +90,6 @@ public class ActivityError extends ActivityBase {
|
||||||
.putExtra("protocol", protocol));
|
.putExtra("protocol", protocol));
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
|
||||||
Log.unexpectedError(getSupportFragmentManager(), ex);
|
|
||||||
}
|
|
||||||
}.execute(ActivityError.this, args, "error:password");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ibSetting.setVisibility(account < 0 ? View.GONE : View.VISIBLE);
|
ibSetting.setVisibility(account < 0 ? View.GONE : View.VISIBLE);
|
||||||
|
|
Loading…
Reference in New Issue