Fix csv mal function exception (#974)

* Disable biometric login after 24 hours of last password login

Fixes #951

Add logic to disable biometric login if the user has not logged in via password in the last 24 hours.

* **UserSettings.kt**
  - Add `lastPasswordLoginTime` attribute to track the last password login time.

* **BiometricPrompt.kt**
  - Add logic to check `lastPasswordLoginTime` and disable biometric login if the last password login was more than 24 hours ago.
  - Add function `updateLastBiometricLoginTime` to update the last biometric login time.

* **AuthScreen.kt**
  - Add logic to reset `lastPasswordLoginTime` when users log in via password.

* **SharedPreferenceUtils.kt**
  - Add functions `updateLastBiometricLoginTime` and `updateLastPasswordLoginTime` to update the respective times in `UserSettings`.

* **ButtonBar.kt**
  - Add logic to reset `lastPasswordLoginTime` when users log in via password.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/yogeshpaliyal/KeyPass/issues/951?shareId=XXXX-XXXX-XXXX-XXXX).

* feat: fix changes

* feat: cleanup

* fix: CSV MalFunction Crash
This commit is contained in:
Yogesh Choudhary Paliyal
2024-09-17 20:38:03 +05:30
committed by GitHub
parent 3618cc5f51
commit 722d2fcd71
2 changed files with 28 additions and 21 deletions

View File

@@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import com.opencsv.CSVReader import com.opencsv.CSVReader
import com.opencsv.exceptions.CsvMalformedLineException
import com.yogeshpaliyal.common.data.AccountModel import com.yogeshpaliyal.common.data.AccountModel
import com.yogeshpaliyal.keypass.R import com.yogeshpaliyal.keypass.R
import com.yogeshpaliyal.keypass.ui.redux.actions.Action import com.yogeshpaliyal.keypass.ui.redux.actions.Action
@@ -23,6 +24,7 @@ class KeePassAccountImporter : AccountsImporter {
val context = LocalContext.current val context = LocalContext.current
LaunchedEffect(key1 = file, block = { LaunchedEffect(key1 = file, block = {
try {
val inputStream = context.contentResolver.openInputStream(file) val inputStream = context.contentResolver.openInputStream(file)
val reader = CSVReader(inputStream?.reader()) val reader = CSVReader(inputStream?.reader())
val myEntries: List<Array<String>> = reader.readAll() val myEntries: List<Array<String>> = reader.readAll()
@@ -46,6 +48,9 @@ class KeePassAccountImporter : AccountsImporter {
} }
resolve(listOfAccounts) resolve(listOfAccounts)
onCompleteOrCancel(ToastAction(R.string.backup_restored)) onCompleteOrCancel(ToastAction(R.string.backup_restored))
} catch (e: CsvMalformedLineException) {
onCompleteOrCancel(ToastAction(R.string.invalid_csv))
}
}) })
LoadingDialog() LoadingDialog()

View File

@@ -10,6 +10,8 @@
<string name="generate_shortcut_short_label">Generate Password</string> <string name="generate_shortcut_short_label">Generate Password</string>
<string name="backup_restored">Backup Restored</string> <string name="backup_restored">Backup Restored</string>
<string name="invalid_csv">Invalid CSV file</string>
<string name="invalid_keyphrase">Invalid Keyphrase</string> <string name="invalid_keyphrase">Invalid Keyphrase</string>
<string name="backup_completed">Backup Completed</string> <string name="backup_completed">Backup Completed</string>