mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
add back error when password is too short (#16876)
This commit is contained in:
parent
3859c25cac
commit
5accaf88b9
@ -85,13 +85,14 @@ export default function CreatePassword({
|
||||
|
||||
const handlePasswordChange = (passwordInput) => {
|
||||
let confirmError = '';
|
||||
let passwordInputError = '';
|
||||
const passwordEvaluation = zxcvbn(passwordInput);
|
||||
const passwordStrengthLabel = getPasswordStrengthLabel(
|
||||
passwordEvaluation.score,
|
||||
t,
|
||||
);
|
||||
const passwordStrengthDescription = passwordStrengthLabel.description;
|
||||
const passwordStrengthInput = t('passwordStrength', [
|
||||
let passwordStrengthDescription = passwordStrengthLabel.description;
|
||||
let passwordStrengthInput = t('passwordStrength', [
|
||||
<span
|
||||
key={passwordEvaluation.score}
|
||||
className={passwordStrengthLabel.className}
|
||||
@ -100,11 +101,20 @@ export default function CreatePassword({
|
||||
</span>,
|
||||
]);
|
||||
|
||||
if (passwordInput.length < 8) {
|
||||
passwordInputError = passwordInput.length
|
||||
? t('passwordNotLongEnough')
|
||||
: '';
|
||||
passwordStrengthInput = null;
|
||||
passwordStrengthDescription = '';
|
||||
}
|
||||
|
||||
if (confirmPassword && passwordInput !== confirmPassword) {
|
||||
confirmError = t('passwordsDontMatch');
|
||||
}
|
||||
|
||||
setPassword(passwordInput);
|
||||
setPasswordError(passwordInputError);
|
||||
setPasswordStrength(passwordStrengthInput);
|
||||
setPasswordStrengthText(passwordStrengthDescription);
|
||||
setConfirmPasswordError(confirmError);
|
||||
@ -175,6 +185,7 @@ export default function CreatePassword({
|
||||
<FormField
|
||||
dataTestId="create-password-new"
|
||||
autoFocus
|
||||
error={passwordError}
|
||||
passwordStrength={passwordStrength}
|
||||
passwordStrengthText={passwordStrengthText}
|
||||
onChange={handlePasswordChange}
|
||||
|
Loading…
Reference in New Issue
Block a user