From b92e251040800ae9acada1063629878143d7b2f8 Mon Sep 17 00:00:00 2001 From: Deep Panchal Date: Mon, 4 Sep 2023 10:11:38 -0500 Subject: [PATCH] fix(auth): use areTokensValid instead of hasAuthenticated Comment from Qui: `hasAuthenticated` indicates the user has authenticated at least once. This is true even when the refresh token expires. I'll add documentation later to make things clearer. Change this to use the areTokensValid property. This means the refresh token expiration is in the future and the user won't need to re-authenticate any time soon. So when areTokensValid = true the login options don't need to be presented. When false the user will want to re-authenticate to get a new refresh token. --- .../crisiscleanup/feature/authentication/RootAuthViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/authentication/src/main/java/com/crisiscleanup/feature/authentication/RootAuthViewModel.kt b/feature/authentication/src/main/java/com/crisiscleanup/feature/authentication/RootAuthViewModel.kt index b8cb8135..a3c48055 100644 --- a/feature/authentication/src/main/java/com/crisiscleanup/feature/authentication/RootAuthViewModel.kt +++ b/feature/authentication/src/main/java/com/crisiscleanup/feature/authentication/RootAuthViewModel.kt @@ -24,7 +24,7 @@ class RootAuthViewModel @Inject constructor( ): ViewModel() { val authState = accountDataRepository.accountData .map { - if (it.hasAuthenticated) { + if (it.areTokensValid) { AuthState.Authenticated(it) } else { AuthState.NotAuthenticated