From 30484803e5147387dc2ffd975cb50ad5ef50488e Mon Sep 17 00:00:00 2001 From: Flavia Handrea Date: Fri, 15 Nov 2024 18:30:14 +0200 Subject: [PATCH] Bug fix for 2FA enabled login flow. --- .../permanent/ui/login/AuthenticationFragment.kt | 7 +++++-- .../permanent/viewmodels/AuthenticationViewModel.kt | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt b/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt index d09cba63..a0aaea48 100644 --- a/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt +++ b/app/src/main/java/org/permanent/permanent/ui/login/AuthenticationFragment.kt @@ -88,11 +88,14 @@ class AuthenticationFragment : PermanentBaseFragment() { private val onAccountCreated = Observer { logSignUpEvents() - startActivity(Intent(context, ArchiveOnboardingActivity::class.java)) - activity?.finish() + startArchiveOnboardingActivity() } private val userMissingDefaultArchiveObserver = Observer { + startArchiveOnboardingActivity() + } + + private fun startArchiveOnboardingActivity() { startActivity(Intent(context, ArchiveOnboardingActivity::class.java)) activity?.finish() } diff --git a/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt b/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt index d1c0eba3..f1008747 100644 --- a/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt +++ b/app/src/main/java/org/permanent/permanent/viewmodels/AuthenticationViewModel.kt @@ -102,7 +102,6 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM authRepository.login(email, password, object : IAuthenticationRepository.IOnLoginListener { override fun onSuccess() { _isBusyState.value = false - prefsHelper.saveUserLoggedIn(true) val defaultArchiveId = prefsHelper.getDefaultArchiveId() if (defaultArchiveId == 0) { @@ -155,6 +154,7 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM archive.thumbURL200, archive.accessRole ) + prefsHelper.saveUserLoggedIn(true) onSignedIn.call() return } @@ -210,7 +210,7 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM object : IAuthenticationRepository.IOnVerifyListener { override fun onSuccess() { _isBusyState.value = false - onSignedIn.call() + onCodeVerified() } override fun onFailed(error: String?) { @@ -227,6 +227,13 @@ class AuthenticationViewModel(application: Application) : ObservableAndroidViewM }) } + fun onCodeVerified() { + val defaultArchiveId = prefsHelper.getDefaultArchiveId() + + if (defaultArchiveId == 0) onUserMissingDefaultArchive.call() + else getArchive(defaultArchiveId) + } + fun updateCodeValues(newValues: List) { _codeValues.value = newValues }