mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Ensure login and password exclude \n. #2263
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
Ensure login and password exclude `\n`
|
||||||
+19
-9
@@ -194,15 +194,17 @@ private fun LoginForm(
|
|||||||
.onTabOrEnterKeyFocusNext(focusManager)
|
.onTabOrEnterKeyFocusNext(focusManager)
|
||||||
.testTag(TestTags.loginEmailUsername)
|
.testTag(TestTags.loginEmailUsername)
|
||||||
.autofill(autofillTypes = listOf(AutofillType.Username), onFill = {
|
.autofill(autofillTypes = listOf(AutofillType.Username), onFill = {
|
||||||
loginFieldState = it
|
val sanitized = it.sanitize()
|
||||||
eventSink(LoginPasswordEvents.SetLogin(it))
|
loginFieldState = sanitized
|
||||||
|
eventSink(LoginPasswordEvents.SetLogin(sanitized))
|
||||||
}),
|
}),
|
||||||
placeholder = {
|
placeholder = {
|
||||||
Text(text = stringResource(CommonStrings.common_username))
|
Text(text = stringResource(CommonStrings.common_username))
|
||||||
},
|
},
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
loginFieldState = it
|
val sanitized = it.sanitize()
|
||||||
eventSink(LoginPasswordEvents.SetLogin(it))
|
loginFieldState = sanitized
|
||||||
|
eventSink(LoginPasswordEvents.SetLogin(sanitized))
|
||||||
},
|
},
|
||||||
keyboardOptions = KeyboardOptions(
|
keyboardOptions = KeyboardOptions(
|
||||||
keyboardType = KeyboardType.Email,
|
keyboardType = KeyboardType.Email,
|
||||||
@@ -224,7 +226,6 @@ private fun LoginForm(
|
|||||||
null
|
null
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
var passwordVisible by remember { mutableStateOf(false) }
|
var passwordVisible by remember { mutableStateOf(false) }
|
||||||
if (state.loginAction is AsyncData.Loading) {
|
if (state.loginAction is AsyncData.Loading) {
|
||||||
// Ensure password is hidden when user submits the form
|
// Ensure password is hidden when user submits the form
|
||||||
@@ -239,12 +240,14 @@ private fun LoginForm(
|
|||||||
.onTabOrEnterKeyFocusNext(focusManager)
|
.onTabOrEnterKeyFocusNext(focusManager)
|
||||||
.testTag(TestTags.loginPassword)
|
.testTag(TestTags.loginPassword)
|
||||||
.autofill(autofillTypes = listOf(AutofillType.Password), onFill = {
|
.autofill(autofillTypes = listOf(AutofillType.Password), onFill = {
|
||||||
passwordFieldState = it
|
val sanitized = it.sanitize()
|
||||||
eventSink(LoginPasswordEvents.SetPassword(it))
|
passwordFieldState = sanitized
|
||||||
|
eventSink(LoginPasswordEvents.SetPassword(sanitized))
|
||||||
}),
|
}),
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
passwordFieldState = it
|
val sanitized = it.sanitize()
|
||||||
eventSink(LoginPasswordEvents.SetPassword(it))
|
passwordFieldState = sanitized
|
||||||
|
eventSink(LoginPasswordEvents.SetPassword(sanitized))
|
||||||
},
|
},
|
||||||
placeholder = {
|
placeholder = {
|
||||||
Text(text = stringResource(CommonStrings.common_password))
|
Text(text = stringResource(CommonStrings.common_password))
|
||||||
@@ -272,6 +275,13 @@ private fun LoginForm(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that the string does not contain any new line characters, which can happen when pasting values.
|
||||||
|
*/
|
||||||
|
private fun String.sanitize(): String {
|
||||||
|
return replace("\n", "")
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun LoginErrorDialog(error: Throwable, onDismiss: () -> Unit) {
|
private fun LoginErrorDialog(error: Throwable, onDismiss: () -> Unit) {
|
||||||
ErrorDialog(
|
ErrorDialog(
|
||||||
|
|||||||
Reference in New Issue
Block a user