diff --git a/app/src/main/java/foundation/e/apps/data/login/LoginSourceGPlay.kt b/app/src/main/java/foundation/e/apps/data/login/LoginSourceGPlay.kt index d5cf5e45b584a4f5fdb3c294a2482007dc9bda92..9a8f06a7635e5c5ee2ad7c10c6d4bace50996138 100644 --- a/app/src/main/java/foundation/e/apps/data/login/LoginSourceGPlay.kt +++ b/app/src/main/java/foundation/e/apps/data/login/LoginSourceGPlay.kt @@ -213,18 +213,18 @@ class LoginSourceGPlay @Inject constructor( } override suspend fun validateAuthData(): ResultSupreme { - val savedAuth = getSavedAuthData() - if (!isAuthDataValid(savedAuth)) { - Timber.i("Validating AuthData...") - val authData = generateAuthData() - authData.data?.let { - saveAuthData(it) - return authData - } - return ResultSupreme.create(ResultStatus.UNKNOWN) + val authObject = getAuthObject() + val authData = authObject.result.data + + Timber.i("Validating AuthData...") + if (isAuthDataValid(authData)) { + return ResultSupreme.Success(authData) } - return ResultSupreme.create(ResultStatus.OK, savedAuth) + clearSavedAuth() + + val newAuthObjectResult = getAuthObject().result + return ResultSupreme.replicate(newAuthObjectResult, newAuthObjectResult.data) } private suspend fun isAuthDataValid(savedAuth: AuthData?) = diff --git a/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt b/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt index 6cbf9999810088217b171e77bf60b2b0564ed520..cb0cf14dded56ed18d7c87f6e60136e23ddaeaa8 100644 --- a/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt +++ b/app/src/main/java/foundation/e/apps/data/login/LoginSourceRepository.kt @@ -40,10 +40,13 @@ class LoginSourceRepository @Inject constructor( if (source::class.java.simpleName in clearAuthTypes) { source.clearSavedAuth() } - if (source is LoginSourceGPlay) { - gplayAuth = source.getAuthObject().result.data + + source.getAuthObject().run { + if (source is LoginSourceGPlay) { + gplayAuth = this.result.data as AuthData? + } + authObjectsLocal.add(this) } - authObjectsLocal.add(source.getAuthObject()) } return authObjectsLocal