PM-15109 only accept numeric values for account pin lock value (#4359)

This commit is contained in:
Dave Severns
2024-11-22 08:59:01 -05:00
committed by GitHub
parent b19e7e1495
commit 1e223b1a2a
4 changed files with 12 additions and 5 deletions

View File

@@ -79,6 +79,7 @@ fun BitwardenUnlockWithPinSwitch(
onUnlockWithPinToggleAction(UnlockWithPinState.Disabled)
pin = ""
},
isPinCreation = true,
)
}

View File

@@ -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")

View File

@@ -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",
),
)
}

View File

@@ -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,
),
)