更新密码校验规则

This commit is contained in:
2024-12-01 15:29:03 +08:00
parent c54d5c914a
commit 784427cfba
3 changed files with 9 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.aiosman.ravenow.AppState
import com.aiosman.ravenow.AppStore
import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.data.api.ErrorCode
import com.aiosman.ravenow.LocalNavController
import com.aiosman.ravenow.R
@@ -43,6 +44,7 @@ import kotlinx.coroutines.launch
@Composable
fun EmailSignupScreen() {
var appColor = LocalAppTheme.current
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
var confirmPassword by remember { mutableStateOf("") }
@@ -71,14 +73,12 @@ fun EmailSignupScreen() {
passwordError = when {
// 非空
password.isEmpty() -> context.getString(R.string.text_error_password_required)
// 包含大写字母
!password.matches(Regex(".*[A-Z].*")) -> context.getString(R.string.text_error_password_format)
// 至少8位
password.length < 8 -> context.getString(R.string.text_error_password_format)
// 至少6位
password.length < 6 -> context.getString(R.string.text_error_password_format)
// 至少一个数字
!password.matches(Regex(".*\\d.*")) -> context.getString(R.string.text_error_password_format)
// 包含小写字母
!password.matches(Regex(".*[a-z].*")) -> context.getString(R.string.text_error_password_format)
// 包含字母
!password.matches(Regex(".*[a-zA-Z].*")) -> context.getString(R.string.text_error_password_format)
else -> null
}
confirmPasswordError = when {
@@ -170,7 +170,7 @@ fun EmailSignupScreen() {
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.background(Color.White)
.background(appColor.background)
) {
StatusBarSpacer()
Box(