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

Commit d43c1365 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

refactor: reorganize login in data, domain, ui layers

parent 4c3e9ca8
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -3,6 +3,5 @@ package foundation.e.apps.data.enums
enum class User {
    NO_GOOGLE,
    ANONYMOUS,
    GOOGLE,
    UNAVAILABLE
    GOOGLE
}
+5 −0
Original line number Diff line number Diff line
package foundation.e.apps.data.login.api

interface LoginManager<T> {
    suspend fun login(): T
}
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019-2022  E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps.data.login.api

import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.models.PlayResponse

interface PlayStoreLoginManager {
    suspend fun login(): AuthData?
    suspend fun validate(authData: AuthData): PlayResponse
}
+15 −7
Original line number Diff line number Diff line
@@ -15,10 +15,15 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps.data.login
package foundation.e.apps.data.login.cleanapk

import foundation.e.apps.data.ResultSupreme
import foundation.e.apps.data.enums.User
import foundation.e.apps.data.login.core.AuthObject
import foundation.e.apps.data.login.core.StoreAuthResult
import foundation.e.apps.data.login.core.StoreAuthenticator
import foundation.e.apps.data.login.core.StoreType
import foundation.e.apps.data.login.state.LoginState
import foundation.e.apps.data.preference.AppLoungeDataStore
import foundation.e.apps.data.preference.AppLoungePreference
import javax.inject.Inject
@@ -33,25 +38,28 @@ class CleanApkAuthenticator @Inject constructor(
    private val appLoungeDataStore: AppLoungeDataStore,
    private val appLoungePreference: AppLoungePreference,
) : StoreAuthenticator {
    override val storeType: StoreType = StoreType.CLEAN_APK

    private val user: User
        get() = appLoungeDataStore.getUser()

    override fun isStoreActive(): Boolean {
        if (user == User.UNAVAILABLE) {
        if (appLoungeDataStore.getLoginState() == LoginState.UNAVAILABLE) {
            /*
             * UNAVAILABLE user means first login is not completed.
             * UNAVAILABLE login state means first login is not completed.
             */
            return false
        }
        return appLoungePreference.isOpenSourceSelected() || appLoungePreference.isPWASelected()
    }

    override suspend fun login(): AuthObject.CleanApk {
        return AuthObject.CleanApk(
    override suspend fun login(): StoreAuthResult {
        return StoreAuthResult(
            authObject = AuthObject.CleanApk(
                ResultSupreme.Success(Unit),
                user,
            )
        )
    }

    override suspend fun logout() {
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
 *
 */

package foundation.e.apps.data.login
package foundation.e.apps.data.login.core

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Loading