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

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

AM: Update authstate all the time

parent 18eee5d5
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -137,11 +137,9 @@ class AccountSettings @AssistedInject constructor(
    }
    }


    fun updateAuthState(authState: AuthState) {
    fun updateAuthState(authState: AuthState) {
        OAuthMurena.newAuthState(authState)?.let { authState ->
        accountManager.setAndVerifyUserData(account, KEY_AUTH_STATE, authState.jsonSerializeString())
        accountManager.setAndVerifyUserData(account, KEY_AUTH_STATE, authState.jsonSerializeString())
        OAuthMurena.saveAuthState(context, account, authState)
        OAuthMurena.saveAuthState(context, account, authState)
    }
    }
    }


    /**
    /**
     * Returns whether users can modify credentials from the account settings screen.
     * Returns whether users can modify credentials from the account settings screen.
+1 −9
Original line number Original line Diff line number Diff line
@@ -26,9 +26,9 @@ import androidx.core.net.toUri
import at.bitfire.davdroid.BuildConfig
import at.bitfire.davdroid.BuildConfig
import at.bitfire.davdroid.settings.Credentials
import at.bitfire.davdroid.settings.Credentials
import at.bitfire.davdroid.sync.account.setAndVerifyUserData
import at.bitfire.davdroid.sync.account.setAndVerifyUserData
import foundation.e.accountmanager.pref.AuthStatePrefUtils
import com.owncloud.android.lib.common.accounts.AccountUtils
import com.owncloud.android.lib.common.accounts.AccountUtils
import foundation.e.accountmanager.AccountTypes
import foundation.e.accountmanager.AccountTypes
import foundation.e.accountmanager.pref.AuthStatePrefUtils
import net.openid.appauth.AuthState
import net.openid.appauth.AuthState
import net.openid.appauth.AuthorizationRequest
import net.openid.appauth.AuthorizationRequest
import net.openid.appauth.AuthorizationServiceConfiguration
import net.openid.appauth.AuthorizationServiceConfiguration
@@ -108,12 +108,4 @@ object OAuthMurena {
            logger.log(Level.INFO, "Saved new authState $stateJson")
            logger.log(Level.INFO, "Saved new authState $stateJson")
        }
        }
    }
    }

    fun newAuthState(authState: AuthState?): AuthState? =
        authState?.apply {
            needsTokenRefresh = scopeSet?.contains("offline_access") != true
            if (BuildConfig.DEBUG) {
                logger.log(Level.INFO, "needsTokenRefresh: $needsTokenRefresh")
            }
        }
}
}