更新密码校验规则

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

View File

@@ -39,7 +39,7 @@
<string name="agree_terms_of_service">我已阅读用户协议</string> <string name="agree_terms_of_service">我已阅读用户协议</string>
<string name="agree_promotion">我同意 Rave Now 推送消息</string> <string name="agree_promotion">我同意 Rave Now 推送消息</string>
<string name="text_error_email_format">邮箱格式错误</string> <string name="text_error_email_format">邮箱格式错误</string>
<string name="text_error_password_format">密码至少为 8 位,包含大写字母、小写字母、数字</string> <string name="text_error_password_format">至少6位包含字母、数字</string>
<string name="text_error_confirm_password_mismatch">密码和确认密码必须相同</string> <string name="text_error_confirm_password_mismatch">密码和确认密码必须相同</string>
<string name="text_error_confirm_password_required">请输入确认密码</string> <string name="text_error_confirm_password_required">请输入确认密码</string>
<string name="error_10001_user_exist">用户已存在</string> <string name="error_10001_user_exist">用户已存在</string>

View File

@@ -38,7 +38,7 @@
<string name="agree_terms_of_service">Yes, I have read and agree to RaveNows Privacy Policy.</string> <string name="agree_terms_of_service">Yes, I have read and agree to RaveNows Privacy Policy.</string>
<string name="agree_promotion">Yes, I want to be added to the Rave Now mailing list.</string> <string name="agree_promotion">Yes, I want to be added to the Rave Now mailing list.</string>
<string name="text_error_email_format">Invalid email</string> <string name="text_error_email_format">Invalid email</string>
<string name="text_error_password_format">The password must be at least 8 characters long and contain a combination of uppercase letters, lowercase letters, and numbers.</string> <string name="text_error_password_format">At least 6 characters and contain letters, and numbers.</string>
<string name="text_error_confirm_password_mismatch">Please ensure that the passwords entered twice are consistent.</string> <string name="text_error_confirm_password_mismatch">Please ensure that the passwords entered twice are consistent.</string>
<string name="text_error_confirm_password_required">Confirm password is required</string> <string name="text_error_confirm_password_required">Confirm password is required</string>
<string name="error_10001_user_exist">User existed</string> <string name="error_10001_user_exist">User existed</string>