rules for change new passwort fix

This commit is contained in:
ogerly 2021-06-15 12:21:18 +02:00
parent dd227e4bb1
commit 37ffb1fc59

View File

@ -20,7 +20,7 @@
</b-row>
<div v-if="!edit_pwd">
<b-row class="mb-3">
<b-row class="mb-5">
<b-col class="col-lg-3 col-md-10 col-sm-10 text-md-left text-lg-right">
<small>{{ $t('form.password_old') }}</small>
</b-col>
@ -43,6 +43,7 @@
</b-input-group>
</b-col>
</b-row>
<b-row class="mb-3">
<b-col class="col-lg-3 col-md-10 col-sm-10 text-md-left text-lg-right">
<small>{{ $t('form.password_new') }}</small>
@ -89,6 +90,26 @@
</b-input-group>
</b-col>
</b-row>
<b-row>
<b-col></b-col>
<b-col>
<transition name="hint" appear>
<div v-if="passwordValidation.errors.length > 0 && !submitted" class="hints">
<ul>
<li v-for="error in passwordValidation.errors" :key="error">
<small>{{ error }}</small>
</li>
</ul>
</div>
<div class="matches" v-else-if="!samePasswords">
<p>
{{ $t('site.signup.dont_match') }}
<i class="ni ni-active-40" color="danger"></i>
</p>
</div>
</transition>
</b-col>
</b-row>
<b-row class="text-right" v-if="!edit_pwd">
<b-col>
@ -165,6 +186,31 @@ export default {
}
},
},
computed: {
samePasswords() {
return this.password === this.passwordNew
},
rules() {
return [
{ message: this.$t('site.signup.lowercase'), regex: /[a-z]+/ },
{ message: this.$t('site.signup.uppercase'), regex: /[A-Z]+/ },
{ message: this.$t('site.signup.minimum'), regex: /.{8,}/ },
{ message: this.$t('site.signup.one_number'), regex: /[0-9]+/ },
]
},
passwordValidation() {
const errors = []
for (const condition of this.rules) {
if (!condition.regex.test(this.passwordNew)) {
errors.push(condition.message)
}
}
if (errors.length === 0) {
return { valid: true, errors }
}
return { valid: false, errors }
},
},
}
</script>
<style></style>