mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2025-12-31 16:38:06 -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.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,29 +24,33 @@ class KeePassAccountImporter : AccountsImporter {
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
LaunchedEffect(key1 = file, block = {
|
LaunchedEffect(key1 = file, block = {
|
||||||
val inputStream = context.contentResolver.openInputStream(file)
|
try {
|
||||||
val reader = CSVReader(inputStream?.reader())
|
val inputStream = context.contentResolver.openInputStream(file)
|
||||||
val myEntries: List<Array<String>> = reader.readAll()
|
val reader = CSVReader(inputStream?.reader())
|
||||||
val headers = myEntries[0]
|
val myEntries: List<Array<String>> = reader.readAll()
|
||||||
val result = myEntries.drop(1).map { data ->
|
val headers = myEntries[0]
|
||||||
headers.zip(data).toMap()
|
val result = myEntries.drop(1).map { data ->
|
||||||
}
|
headers.zip(data).toMap()
|
||||||
val listOfAccounts = ArrayList<AccountModel>()
|
}
|
||||||
result.forEach {
|
val listOfAccounts = ArrayList<AccountModel>()
|
||||||
listOfAccounts.add(
|
result.forEach {
|
||||||
AccountModel(
|
listOfAccounts.add(
|
||||||
title = it["Title"],
|
AccountModel(
|
||||||
notes = it["Notes"],
|
title = it["Title"],
|
||||||
password = it["Password"],
|
notes = it["Notes"],
|
||||||
username = it["Username"],
|
password = it["Password"],
|
||||||
site = it["URL"],
|
username = it["Username"],
|
||||||
tags = it["Group"],
|
site = it["URL"],
|
||||||
secret = if (it["TOTP"].isNullOrBlank()) null else it["TOTP"]
|
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()
|
LoadingDialog()
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user