Skip to content

Commit 212effe

Browse files
committed
feat: Add warning when login contains control characters
1 parent b5607a6 commit 212effe

File tree

1 file changed

+15
-0
lines changed
  • src/main/kotlin/org/datepollsystems/waiterrobot/mediator/ui/login

1 file changed

+15
-0
lines changed

src/main/kotlin/org/datepollsystems/waiterrobot/mediator/ui/login/LoginScreen.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ fun LoginScreen(vm: LoginViewModel) {
3333
var mail by remember { mutableStateOf("") }
3434
var password by remember { mutableStateOf("") }
3535
var passwordVisible by remember { mutableStateOf(false) }
36+
val loginContainsControlChar by remember {
37+
derivedStateOf { mail.any { Character.isISOControl(it.code) } || password.any { Character.isISOControl(it.code) } }
38+
}
3639

3740
Column(
3841
modifier = Modifier.padding(50.dp).requiredWidthIn(max = 500.dp),
@@ -107,6 +110,18 @@ fun LoginScreen(vm: LoginViewModel) {
107110
},
108111
)
109112

113+
if (loginContainsControlChar) {
114+
Card(
115+
shape = RoundedCornerShape(10),
116+
border = BorderStroke(2.dp, Color.Yellow.copy(0.8f)),
117+
backgroundColor = Color.Yellow.copy(0.5f),
118+
) {
119+
Box(modifier = Modifier.padding(vertical = 20.dp, horizontal = 50.dp)) {
120+
Text("Email or password contains control characters. Probably a copy past error.")
121+
}
122+
}
123+
}
124+
110125
OutlinedButton(
111126
onClick = { vm.doLogin(mail, password) }
112127
) {

0 commit comments

Comments
 (0)