mirror of
https://github.com/bitwarden/android.git
synced 2026-03-12 05:04:17 -05:00
PM-15109 only accept numeric values for account pin lock value (#4359)
This commit is contained in:
@@ -79,6 +79,7 @@ fun BitwardenUnlockWithPinSwitch(
|
||||
onUnlockWithPinToggleAction(UnlockWithPinState.Disabled)
|
||||
pin = ""
|
||||
},
|
||||
isPinCreation = true,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
||||
* @param onCancelClick A callback for when the "Cancel" button is clicked.
|
||||
* @param onSubmitClick A callback for when the "Submit" button is clicked.
|
||||
* @param onDismissRequest A callback for when the dialog is requesting to be dismissed.
|
||||
* @param isPinCreation A flag for determining if the dialog is being used for PIN creation. We
|
||||
* want to restrict PINs to numeric values but also support any existing PINs with non-numeric
|
||||
* characters.
|
||||
*/
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Suppress("LongMethod")
|
||||
@@ -51,6 +54,7 @@ fun PinInputDialog(
|
||||
onCancelClick: () -> Unit,
|
||||
onSubmitClick: (String) -> Unit,
|
||||
onDismissRequest: () -> Unit,
|
||||
isPinCreation: Boolean = false,
|
||||
) {
|
||||
var pin by remember { mutableStateOf(value = "") }
|
||||
Dialog(
|
||||
@@ -107,7 +111,9 @@ fun PinInputDialog(
|
||||
label = stringResource(id = R.string.pin),
|
||||
value = pin,
|
||||
autoFocus = true,
|
||||
onValueChange = { pin = it },
|
||||
onValueChange = { newValue ->
|
||||
pin = newValue.filter { it.isDigit() || !isPinCreation }
|
||||
},
|
||||
keyboardType = KeyboardType.Number,
|
||||
modifier = Modifier
|
||||
.testTag(tag = "AlertInputField")
|
||||
|
||||
@@ -388,7 +388,7 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
||||
composeTestRule
|
||||
.onAllNodesWithText(text = "PIN")
|
||||
.filterToOne(hasAnyAncestor(isDialog()))
|
||||
.performTextInput("PIN")
|
||||
.performTextInput("1234")
|
||||
composeTestRule
|
||||
.onAllNodesWithText(text = "Submit")
|
||||
.filterToOne(hasAnyAncestor(isDialog()))
|
||||
@@ -397,7 +397,7 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
VaultAddEditAction.Common.PinFido2SetUpSubmit(
|
||||
pin = "PIN",
|
||||
pin = "1234",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1788,7 +1788,7 @@ class VaultItemListingScreenTest : BaseComposeTest() {
|
||||
composeTestRule
|
||||
.onAllNodesWithText(text = "PIN")
|
||||
.filterToOne(hasAnyAncestor(isDialog()))
|
||||
.performTextInput("PIN")
|
||||
.performTextInput("1234")
|
||||
composeTestRule
|
||||
.onAllNodesWithText(text = "Submit")
|
||||
.filterToOne(hasAnyAncestor(isDialog()))
|
||||
@@ -1797,7 +1797,7 @@ class VaultItemListingScreenTest : BaseComposeTest() {
|
||||
verify {
|
||||
viewModel.trySendAction(
|
||||
VaultItemListingsAction.PinFido2SetUpSubmit(
|
||||
pin = "PIN",
|
||||
pin = "1234",
|
||||
selectedCipherId = selectedCipherId,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user