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

Commit 14cab502 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

mail: Allow openid murena accounts

parent e73788f5
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -128,11 +128,6 @@ object AccountManagerHelper {
        return ContentResolver.getSyncAutomatically(account, AccountManagerConstants.MAIL_CONTENT_AUTHORITY)
    }

    fun isOpenIdAccount(accountManager: AccountManager, account: Account): Boolean {
        val authState = accountManager.getUserData(account, AccountManagerConstants.KEY_AUTH_STATE)
        return authState != null && authState.trim { it <= ' ' }.isNotEmpty()
    }

    /**
     * Update oAuthState for google accounts which is logged in using accountManager
     * @return is the update operation successful or not
+8 −11
Original line number Diff line number Diff line
@@ -138,12 +138,7 @@ internal class EeloAccountCreator(context: Context) : KoinComponent {
        for (account in accountList) {
            val emailId = accountManager.getUserData(account, AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY)
            val isInvalidAccount = AccountManagerHelper.isInvalidEmail(emailId) || !AccountManagerHelper.isSyncable(account)
            val isOpenId = AccountManagerHelper.isOpenIdAccount(accountManager, account)
            val shouldSkip = when (accountType) {
                AccountManagerConstants.EELO_ACCOUNT_TYPE -> isInvalidAccount || isOpenId
                else -> isInvalidAccount || !isOpenId
            }
            if (shouldSkip) {
            if (isInvalidAccount) {
                continue
            }

@@ -153,12 +148,14 @@ internal class EeloAccountCreator(context: Context) : KoinComponent {
                .findAny()

            if (!existenceAccount.isPresent) {
                if (accountType == AccountManagerConstants.EELO_ACCOUNT_TYPE) {
                    val password = accountManager.getPassword(account)
                    createAccount(emailId, password, null, accountType)
                } else {
                val authState = accountManager.getUserData(account, AccountManagerConstants.KEY_AUTH_STATE)
                val password = accountManager.getPassword(account)
                val isOpenId = authState != null && authState.trim { it <= ' ' }.isNotEmpty()

                if (isOpenId) {
                    createAccount(emailId, "", authState, accountType)
                } else if (!password.isNullOrEmpty()) {
                    createAccount(emailId, password, null, accountType)
                }
            }
        }