Added solution for 535 5.7.3 Authentication unsuccessful

This commit is contained in:
M66B 2023-03-04 11:00:25 +01:00
parent ad83451220
commit 46d3d8d31c
5 changed files with 77 additions and 15 deletions

View File

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2023 by Marcel Bokhorst (M66B)
*/
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_OAUTH;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
@ -68,23 +70,43 @@ public class ActivityError extends ActivityBase {
String message = intent.getStringExtra("message");
String provider = intent.getStringExtra("provider");
long account = intent.getLongExtra("account", -1L);
long identity = intent.getLongExtra("identity", -1L);
int protocol = intent.getIntExtra("protocol", -1);
int auth_type = intent.getIntExtra("auth_type", -1);
boolean authorize = intent.getBooleanExtra("authorize", false);
String personal = intent.getStringExtra("personal");
String address = intent.getStringExtra("address");
int faq = intent.getIntExtra("faq", -1);
tvTitle.setText(title);
tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
tvMessage.setText(message);
btnPassword.setText(authorize ? R.string.title_setup_oauth_authorize : R.string.title_password);
btnPassword.setCompoundDrawablesRelativeWithIntrinsicBounds(
0, 0,
authorize ? R.drawable.twotone_check_24 : R.drawable.twotone_edit_24, 0);
btnPassword.setVisibility(account < 0 ? View.GONE : View.VISIBLE);
btnPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("target", "accounts")
.putExtra("id", account)
.putExtra("protocol", protocol));
if (authorize)
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("target", "oauth")
.putExtra("id", provider)
.putExtra("name", "Outlook")
.putExtra("askAccount", true)
.putExtra("askTenant", true)
.putExtra("personal", personal)
.putExtra("address", address));
else
startActivity(new Intent(ActivityError.this, ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("target", "accounts")
.putExtra("id", account)
.putExtra("protocol", protocol));
finish();
}
});

View File

@ -264,7 +264,13 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
onEditAccount(intent);
else if ("identities".equals(target) && id > 0)
onEditIdentity(intent);
else {
else if ("oauth".equals(target)) {
FragmentOAuth fragment = new FragmentOAuth();
fragment.setArguments(intent.getExtras());
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("quick");
fragmentTransaction.commit();
} else {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if ("accounts".equals(target))
fragmentTransaction.replace(R.id.content_frame, new FragmentAccounts()).addToBackStack("accounts");

View File

@ -4817,6 +4817,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onHelp(TupleMessageEx message) {
if (message.error != null &&
message.error.contains("535 5.7.3 Authentication unsuccessful")) {
Intent intent = new Intent(context, ActivityError.class);
intent.setAction("535:" + message.identity);
intent.putExtra("title", "535 5.7.3 Authentication unsuccessful");
intent.putExtra("message", message.error);
intent.putExtra("provider", "outlookgraph");
intent.putExtra("account", message.account);
intent.putExtra("identity", message.identity);
intent.putExtra("authorize", true);
intent.putExtra("personal", message.identityName);
intent.putExtra("address", message.identityEmail);
intent.putExtra("faq", 14);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return;
}
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, ibError);
int order = 0;

View File

@ -482,11 +482,30 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
if (ex instanceof AuthenticationFailedException &&
ex.getMessage() != null &&
ex.getMessage().contains("535 5.7.3 Authentication unsuccessful")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Helper.SUPPORT_URI))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent piFix = PendingIntentCompat.getActivity(
this, PI_FIX, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(piFix);
EntityIdentity identity = db.identity().getIdentity(message.identity);
if (identity == null) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Helper.SUPPORT_URI))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent piFix = PendingIntentCompat.getActivity(
this, PI_FIX, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(piFix);
} else {
Intent intent = new Intent(this, ActivityError.class);
intent.setAction("535:" + identity.id);
intent.putExtra("title", ex.getMessage());
intent.putExtra("message", Log.formatThrowable(ex, "\n", false));
intent.putExtra("provider", "outlookgraph");
intent.putExtra("account", identity.account);
intent.putExtra("identity", identity.id);
intent.putExtra("authorize", true);
intent.putExtra("personal", identity.name);
intent.putExtra("address", identity.user);
intent.putExtra("faq", 14);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntentCompat.getActivity(
this, ActivityError.PI_ERROR, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pi);
}
}
nm.notify("send:" + message.id,

View File

@ -43,11 +43,11 @@
android:layout_height="wrap_content"
android:drawableStart="@drawable/twotone_warning_24"
android:drawablePadding="6dp"
app:drawableTint="?attr/colorWarning"
android:text="Error"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"
app:drawableTint="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -69,13 +69,10 @@
<Button
android:id="@+id/btnPassword"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:drawableEnd="@drawable/twotone_edit_24"
android:drawablePadding="6dp"
android:tag="disable"
android:text="@string/title_password"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />