mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2025-12-31 09:09:52 -06:00
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:
committed by
GitHub
parent
3618cc5f51
commit
722d2fcd71
@@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.opencsv.CSVReader
|
||||
import com.opencsv.exceptions.CsvMalformedLineException
|
||||
import com.yogeshpaliyal.common.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.ui.redux.actions.Action
|
||||
@@ -23,29 +24,33 @@ class KeePassAccountImporter : AccountsImporter {
|
||||
val context = LocalContext.current
|
||||
|
||||
LaunchedEffect(key1 = file, block = {
|
||||
val inputStream = context.contentResolver.openInputStream(file)
|
||||
val reader = CSVReader(inputStream?.reader())
|
||||
val myEntries: List<Array<String>> = reader.readAll()
|
||||
val headers = myEntries[0]
|
||||
val result = myEntries.drop(1).map { data ->
|
||||
headers.zip(data).toMap()
|
||||
}
|
||||
val listOfAccounts = ArrayList<AccountModel>()
|
||||
result.forEach {
|
||||
listOfAccounts.add(
|
||||
AccountModel(
|
||||
title = it["Title"],
|
||||
notes = it["Notes"],
|
||||
password = it["Password"],
|
||||
username = it["Username"],
|
||||
site = it["URL"],
|
||||
tags = it["Group"],
|
||||
secret = if (it["TOTP"].isNullOrBlank()) null else it["TOTP"]
|
||||
try {
|
||||
val inputStream = context.contentResolver.openInputStream(file)
|
||||
val reader = CSVReader(inputStream?.reader())
|
||||
val myEntries: List<Array<String>> = reader.readAll()
|
||||
val headers = myEntries[0]
|
||||
val result = myEntries.drop(1).map { data ->
|
||||
headers.zip(data).toMap()
|
||||
}
|
||||
val listOfAccounts = ArrayList<AccountModel>()
|
||||
result.forEach {
|
||||
listOfAccounts.add(
|
||||
AccountModel(
|
||||
title = it["Title"],
|
||||
notes = it["Notes"],
|
||||
password = it["Password"],
|
||||
username = it["Username"],
|
||||
site = it["URL"],
|
||||
tags = it["Group"],
|
||||
secret = if (it["TOTP"].isNullOrBlank()) null else it["TOTP"]
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
resolve(listOfAccounts)
|
||||
onCompleteOrCancel(ToastAction(R.string.backup_restored))
|
||||
} catch (e: CsvMalformedLineException) {
|
||||
onCompleteOrCancel(ToastAction(R.string.invalid_csv))
|
||||
}
|
||||
resolve(listOfAccounts)
|
||||
onCompleteOrCancel(ToastAction(R.string.backup_restored))
|
||||
})
|
||||
|
||||
LoadingDialog()
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<string name="generate_shortcut_short_label">Generate Password</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="backup_completed">Backup Completed</string>
|
||||
|
||||
Reference in New Issue
Block a user