Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9500929 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Use an email address to identify an account instead of a username

parent 369e8c24
Loading
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -7,18 +7,15 @@ import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;

import io.eelo.mail.activity.Accounts;
import io.eelo.mail.mail.AuthenticationFailedException;
import io.eelo.mail.mail.OAuth2NeedUserPromptException;
import io.eelo.mail.mail.oauth.OAuth2TokenProvider;

import static io.eelo.mail.account.OAuthConstants.ACCOUNT_USER_NAME_KEY;
import static io.eelo.mail.account.OAuthConstants.ACCOUNT_EMAIL_ADDRESS_KEY;
import static io.eelo.mail.account.OAuthConstants.AUTH_TOKEN_TYPE;
import static io.eelo.mail.account.OAuthConstants.EELO_ACCOUNT_TYPE;
import static io.eelo.mail.account.OAuthConstants.GOOGLE_ACCOUNT_TYPE;
@@ -88,7 +85,7 @@ public class K9OAuth2TokenProvider extends OAuth2TokenProvider {
        if (accounts.size() > 0) {
            for (Account account : accounts) {
                String accountEmailId = accountManager.getUserData(account,
                        ACCOUNT_USER_NAME_KEY);
                        ACCOUNT_EMAIL_ADDRESS_KEY);
                if (emailId.equals(accountEmailId)) {
                    final CountDownLatch countDownLatch = new CountDownLatch(1);
                    accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, new Bundle(),
+1 −1
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@ package io.eelo.mail.account;
public class OAuthConstants {
    public static final String EELO_ACCOUNT_TYPE = "bitfire.at.davdroid.eelo";
    public static final String GOOGLE_ACCOUNT_TYPE = "bitfire.at.davdroid.google";
    public static final String ACCOUNT_USER_NAME_KEY = "user_name";
    public static final String ACCOUNT_EMAIL_ADDRESS_KEY = "email_address";
    static final String AUTH_TOKEN_TYPE = "oauth2-access-token";
}
+3 −3
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ import io.eelo.mail.mailstore.StorageManager;
import io.eelo.mail.preferences.SettingsExporter;
import de.cketti.library.changelog.ChangeLog;

import static io.eelo.mail.account.OAuthConstants.ACCOUNT_USER_NAME_KEY;
import static io.eelo.mail.account.OAuthConstants.ACCOUNT_EMAIL_ADDRESS_KEY;
import static io.eelo.mail.account.OAuthConstants.EELO_ACCOUNT_TYPE;
import static io.eelo.mail.account.OAuthConstants.GOOGLE_ACCOUNT_TYPE;

@@ -480,14 +480,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener
                {
                    for (android.accounts.Account eeloAccount : eeloAccounts) {
                        String emailId = accountManager.getUserData(eeloAccount,
                                ACCOUNT_USER_NAME_KEY);
                                ACCOUNT_EMAIL_ADDRESS_KEY);
                        String password = accountManager.getPassword(eeloAccount);
                        EeloAccountCreator.createAccount(this, emailId, password);
                    }

                    for (android.accounts.Account googleAccount : googleAccounts) {
                        String emailId = accountManager.getUserData(googleAccount,
                                ACCOUNT_USER_NAME_KEY);
                                ACCOUNT_EMAIL_ADDRESS_KEY);
                        GoogleAccountCreator.createAccount(this, emailId);
                    }