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

Commit cbe1bf21 authored by Nihar Thakkar's avatar Nihar Thakkar Committed by Sumit Pundir
Browse files

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

parent 942f071c
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -10,8 +10,6 @@ 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;
@@ -22,7 +20,7 @@ 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;
@@ -92,7 +90,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,7 +3,7 @@ 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
@@ -103,7 +103,7 @@ import io.eelo.mail.view.ColorChip;
import de.cketti.library.changelog.ChangeLog;
import timber.log.Timber;

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;

@@ -416,14 +416,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);
                    }