Merge pull request #2934 from bahadirsofuoglu/password-meter-issue

Password meter dynamic changes problem solved
pull/2940/head
Tuğçe Küçükoğlu 2022-09-05 10:35:06 +03:00 committed by GitHub
commit cdc029e472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 46 additions and 32 deletions

View File

@ -205,6 +205,7 @@ export default {
onFocus(event) { onFocus(event) {
this.focused = true; this.focused = true;
if (this.feedback) { if (this.feedback) {
this.setPasswordMeter(this.modelValue)
this.overlayVisible = true; this.overlayVisible = true;
} }
@ -212,6 +213,7 @@ export default {
}, },
onBlur(event) { onBlur(event) {
this.focused = false; this.focused = false;
if (this.feedback) { if (this.feedback) {
this.overlayVisible = false; this.overlayVisible = false;
} }
@ -221,39 +223,8 @@ export default {
onKeyUp(event) { onKeyUp(event) {
if (this.feedback) { if (this.feedback) {
const value = event.target.value; const value = event.target.value;
let label = null;
let meter = null;
switch (this.testStrength(value)) { const {meter,label} = this.checkPasswordStrength(value);
case 1:
label = this.weakText;
meter = {
strength: 'weak',
width: '33.33%'
};
break;
case 2:
label = this.mediumText;
meter = {
strength: 'medium',
width: '66.66%'
};
break;
case 3:
label = this.strongText;
meter = {
strength: 'strong',
width: '100%'
};
break;
default:
label = this.promptText;
meter = null;
break;
}
this.meter = meter; this.meter = meter;
this.infoText = label; this.infoText = label;
@ -269,6 +240,49 @@ export default {
} }
} }
}, },
setPasswordMeter() {
if(!this.feedback || !this.modelValue) return;
const {meter,label} = this.checkPasswordStrength(this.modelValue);
this.meter = meter;
this.infoText = label;
if (!this.overlayVisible) {
this.overlayVisible = true;
}
},
checkPasswordStrength(value) {
let label = null;
let meter = null;
switch (this.testStrength(value)) {
case 1:
label = this.weakText;
meter = {
strength: 'weak',
width: '33.33%'
};
break;
case 2:
label = this.mediumText;
meter = {
strength: 'medium',
width: '66.66%'
};
break;
case 3:
label = this.strongText;
meter = {
strength: 'strong',
width: '100%'
};
break;
default:
label = this.promptText;
meter = null;
break;
}
return { label, meter };
},
onInvalid(event) { onInvalid(event) {
this.$emit('invalid', event); this.$emit('invalid', event);
}, },