mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-30 13:57:47 +00:00
fix crash due to passphrase caching after biom. authentication expired (#3141)
* fix crash due to passphrase caching after biom. authentication expired * fix: add missing imports --------- Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
@@ -44,6 +44,7 @@ import javax.inject.Inject
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import logcat.LogPriority.ERROR
|
import logcat.LogPriority.ERROR
|
||||||
|
import logcat.asLog
|
||||||
import logcat.logcat
|
import logcat.logcat
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@@ -192,8 +193,6 @@ class AutofillDecryptActivity : BasePGPActivity() {
|
|||||||
Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillInDataset) },
|
Intent().apply { putExtra(AutofillManager.EXTRA_AUTHENTICATION_RESULT, fillInDataset) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (features.isEnabled(EnablePGPPassphraseCache))
|
|
||||||
settings.edit { putBoolean(PreferenceKeys.CLEAR_PASSPHRASE_CACHE, clearCache) }
|
|
||||||
}
|
}
|
||||||
withContext(dispatcherProvider.main()) { finish() }
|
withContext(dispatcherProvider.main()) { finish() }
|
||||||
}
|
}
|
||||||
@@ -218,9 +217,15 @@ class AutofillDecryptActivity : BasePGPActivity() {
|
|||||||
}
|
}
|
||||||
.onSuccess { result ->
|
.onSuccess { result ->
|
||||||
return runCatching {
|
return runCatching {
|
||||||
if (features.isEnabled(EnablePGPPassphraseCache)) {
|
runCatching {
|
||||||
passphraseCache.cachePassphrase(this, identifiers.first(), password)
|
if (features.isEnabled(EnablePGPPassphraseCache)) {
|
||||||
}
|
passphraseCache.cachePassphrase(this, identifiers.first(), password)
|
||||||
|
settings.edit {
|
||||||
|
putBoolean(PreferenceKeys.CLEAR_PASSPHRASE_CACHE, clearCache)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onFailure { e -> logcat { e.asLog() } }
|
||||||
val entry = passwordEntryFactory.create(result.toByteArray())
|
val entry = passwordEntryFactory.create(result.toByteArray())
|
||||||
AutofillPreferences.credentialsFromStoreEntry(this, file, entry, directoryStructure)
|
AutofillPreferences.credentialsFromStoreEntry(this, file, entry, directoryStructure)
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,8 @@ import app.passwordstore.util.features.Feature.EnablePGPPassphraseCache
|
|||||||
import app.passwordstore.util.features.Features
|
import app.passwordstore.util.features.Features
|
||||||
import app.passwordstore.util.settings.Constants
|
import app.passwordstore.util.settings.Constants
|
||||||
import app.passwordstore.util.settings.PreferenceKeys
|
import app.passwordstore.util.settings.PreferenceKeys
|
||||||
|
import com.github.michaelbull.result.onFailure
|
||||||
|
import com.github.michaelbull.result.runCatching
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -41,6 +43,7 @@ import kotlinx.coroutines.flow.first
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import logcat.LogPriority.ERROR
|
import logcat.LogPriority.ERROR
|
||||||
|
import logcat.asLog
|
||||||
import logcat.logcat
|
import logcat.logcat
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@@ -214,13 +217,17 @@ class DecryptActivity : BasePGPActivity() {
|
|||||||
clearCache = bundle.getBoolean(PasswordDialog.PASSWORD_CLEAR_KEY)
|
clearCache = bundle.getBoolean(PasswordDialog.PASSWORD_CLEAR_KEY)
|
||||||
lifecycleScope.launch(dispatcherProvider.main()) {
|
lifecycleScope.launch(dispatcherProvider.main()) {
|
||||||
decryptWithPassphrase(passphrase, gpgIdentifiers, authResult) {
|
decryptWithPassphrase(passphrase, gpgIdentifiers, authResult) {
|
||||||
if (authResult is BiometricResult.Success) {
|
runCatching {
|
||||||
passphraseCache.cachePassphrase(
|
if (authResult is BiometricResult.Success) {
|
||||||
this@DecryptActivity,
|
passphraseCache.cachePassphrase(
|
||||||
gpgIdentifiers.first(),
|
this@DecryptActivity,
|
||||||
passphrase,
|
gpgIdentifiers.first(),
|
||||||
)
|
passphrase,
|
||||||
}
|
)
|
||||||
|
settings.edit { putBoolean(PreferenceKeys.CLEAR_PASSPHRASE_CACHE, clearCache) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onFailure { e -> logcat { e.asLog() } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,8 +244,6 @@ class DecryptActivity : BasePGPActivity() {
|
|||||||
val outputStream = ByteArrayOutputStream()
|
val outputStream = ByteArrayOutputStream()
|
||||||
val result = repository.decrypt(passphrase, identifiers, message, outputStream)
|
val result = repository.decrypt(passphrase, identifiers, message, outputStream)
|
||||||
if (result.isOk) {
|
if (result.isOk) {
|
||||||
if (features.isEnabled(EnablePGPPassphraseCache))
|
|
||||||
settings.edit { putBoolean(PreferenceKeys.CLEAR_PASSPHRASE_CACHE, clearCache) }
|
|
||||||
val entry = passwordEntryFactory.create(result.value.toByteArray())
|
val entry = passwordEntryFactory.create(result.value.toByteArray())
|
||||||
passwordEntry = entry
|
passwordEntry = entry
|
||||||
createPasswordUI(entry)
|
createPasswordUI(entry)
|
||||||
|
Reference in New Issue
Block a user