feat(auth): enhance password policy with stronger requirements
Update password validation across authentication screens to require minimum 8 characters with uppercase letters, lowercase letters, and numbers. Changes applied to ForgotPasswordScreen, RegisterStep3Profile, and AccountSecurityScreen. LoginScreen password validation was removed as it occurs post-authentication.
This commit is contained in:
@@ -115,8 +115,20 @@ export const ForgotPasswordScreen: React.FC = () => {
|
|||||||
showPrompt({ title: '提示', message: '请输入验证码', type: 'warning' });
|
showPrompt({ title: '提示', message: '请输入验证码', type: 'warning' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newPassword.length < 6) {
|
if (newPassword.length < 8) {
|
||||||
showPrompt({ title: '提示', message: '新密码至少 6 位', type: 'warning' });
|
showPrompt({ title: '提示', message: '新密码至少 8 位', type: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[A-Z]/.test(newPassword)) {
|
||||||
|
showPrompt({ title: '提示', message: '新密码必须包含大写字母', type: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[a-z]/.test(newPassword)) {
|
||||||
|
showPrompt({ title: '提示', message: '新密码必须包含小写字母', type: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[0-9]/.test(newPassword)) {
|
||||||
|
showPrompt({ title: '提示', message: '新密码必须包含数字', type: 'warning' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newPassword !== confirmPassword) {
|
if (newPassword !== confirmPassword) {
|
||||||
|
|||||||
@@ -84,10 +84,6 @@ export const LoginScreen: React.FC = () => {
|
|||||||
showPrompt({ title: '提示', message: '请输入密码', type: 'warning' });
|
showPrompt({ title: '提示', message: '请输入密码', type: 'warning' });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (password.length < 6) {
|
|
||||||
showPrompt({ title: '提示', message: '密码长度不能少于6位', type: 'warning' });
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,14 @@ export const RegisterStep3Profile: React.FC<RegisterStepProps> = ({
|
|||||||
|
|
||||||
if (!formData.password) {
|
if (!formData.password) {
|
||||||
newErrors.password = '请输入密码';
|
newErrors.password = '请输入密码';
|
||||||
} else if (formData.password.length < 6) {
|
} else if (formData.password.length < 8) {
|
||||||
newErrors.password = '密码长度不能少于6位';
|
newErrors.password = '密码长度不能少于8位';
|
||||||
|
} else if (!/[A-Z]/.test(formData.password)) {
|
||||||
|
newErrors.password = '密码必须包含大写字母';
|
||||||
|
} else if (!/[a-z]/.test(formData.password)) {
|
||||||
|
newErrors.password = '密码必须包含小写字母';
|
||||||
|
} else if (!/[0-9]/.test(formData.password)) {
|
||||||
|
newErrors.password = '密码必须包含数字';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.password !== formData.confirmPassword) {
|
if (formData.password !== formData.confirmPassword) {
|
||||||
@@ -172,7 +178,7 @@ export const RegisterStep3Profile: React.FC<RegisterStepProps> = ({
|
|||||||
})}
|
})}
|
||||||
|
|
||||||
{/* 密码 */}
|
{/* 密码 */}
|
||||||
{renderInput('密码', 'password', '至少6位', {
|
{renderInput('密码', 'password', '至少8位,含大小写字母和数字', {
|
||||||
secureTextEntry: true,
|
secureTextEntry: true,
|
||||||
showToggle: true,
|
showToggle: true,
|
||||||
toggleValue: showPassword,
|
toggleValue: showPassword,
|
||||||
|
|||||||
@@ -149,8 +149,20 @@ export const AccountSecurityScreen: React.FC = () => {
|
|||||||
showPrompt({ title: '提示', message: '请输入邮箱验证码', type: 'warning' });
|
showPrompt({ title: '提示', message: '请输入邮箱验证码', type: 'warning' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newPassword.length < 6) {
|
if (newPassword.length < 8) {
|
||||||
showPrompt({ title: '提示', message: '新密码至少 6 位', type: 'warning' });
|
showPrompt({ title: '提示', message: '新密码至少 8 位', type: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[A-Z]/.test(newPassword)) {
|
||||||
|
showPrompt({ title: '提示', message: '新密码必须包含大写字母', type: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[a-z]/.test(newPassword)) {
|
||||||
|
showPrompt({ title: '提示', message: '新密码必须包含小写字母', type: 'warning' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/[0-9]/.test(newPassword)) {
|
||||||
|
showPrompt({ title: '提示', message: '新密码必须包含数字', type: 'warning' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newPassword !== confirmPassword) {
|
if (newPassword !== confirmPassword) {
|
||||||
@@ -297,7 +309,7 @@ export const AccountSecurityScreen: React.FC = () => {
|
|||||||
<MaterialCommunityIcons name="lock-plus-outline" size={20} color={colors.text.secondary} style={styles.inputIcon} />
|
<MaterialCommunityIcons name="lock-plus-outline" size={20} color={colors.text.secondary} style={styles.inputIcon} />
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
placeholder="新密码(至少6位)"
|
placeholder="新密码(至少8位,含大小写字母和数字)"
|
||||||
placeholderTextColor={colors.text.hint}
|
placeholderTextColor={colors.text.hint}
|
||||||
value={newPassword}
|
value={newPassword}
|
||||||
onChangeText={setNewPassword}
|
onChangeText={setNewPassword}
|
||||||
|
|||||||
Reference in New Issue
Block a user