remove base-input from ResetPassword.vue

This commit is contained in:
ogerly 2021-06-12 15:15:25 +02:00
parent 04fa666590
commit ee853c63b8

View File

@ -20,38 +20,63 @@
<b-col lg="6" md="8"> <b-col lg="6" md="8">
<b-card no-body class="border-0" style="background-color: #ebebeba3 !important"> <b-card no-body class="border-0" style="background-color: #ebebeba3 !important">
<b-card-body class="p-4"> <b-card-body class="p-4">
<validation-observer v-slot="{ handleSubmit }" ref="formValidator"> <validation-observer ref="observer" v-slot="{ handleSubmit }">
<b-form role="form" @submit.prevent="handleSubmit(onSubmit)"> <b-form role="form" @submit.prevent="handleSubmit(onSubmit)">
<b-form-group :label="$t('form.password')"> <validation-provider
:name="$t('form.password')"
:rules="{ required: true }"
v-slot="validationContext"
>
<b-form-group
class="mb-5"
:label="$t('form.password')"
label-for="resetPassword"
>
<b-input-group>
<b-form-input
id="resetPassword"
:name="$t('form.password')"
v-model="form.password"
:placeholder="$t('form.password')"
:type="passwordVisible ? 'text' : 'password'"
:state="getValidationState(validationContext)"
aria-describedby="resetPasswordLiveFeedback"
></b-form-input>
<b-input-group-append>
<b-button variant="outline-primary" @click="togglePasswordVisibility">
<b-icon :icon="passwordVisible ? 'eye' : 'eye-slash'" />
</b-button>
</b-input-group-append>
</b-input-group>
<b-form-invalid-feedback id="resetPasswordLiveFeedback">
{{ validationContext.errors[0] }}
</b-form-invalid-feedback>
</b-form-group>
</validation-provider>
<b-form-group
class="mb-5"
:label="$t('form.passwordRepeat')"
label-for="resetPasswordRepeat"
>
<b-input-group> <b-input-group>
<b-form-input <b-form-input
class="mb-0" id="resetPasswordRepeat"
v-model="password" :name="$t('form.passwordRepeat')"
name="password" v-model.lazy="form.passwordRepeat"
:class="{ valid: passwordValidation.valid }" :placeholder="$t('form.passwordRepeat')"
:type="passwordVisible ? 'text' : 'password'" :type="passwordVisibleRepeat ? 'text' : 'password'"
prepend-icon="ni ni-lock-circle-open"
:placeholder="$t('form.password')"
></b-form-input> ></b-form-input>
<b-input-group-append> <b-input-group-append>
<b-button variant="outline-primary" @click="togglePasswordVisibility"> <b-button variant="outline-primary" @click="togglePasswordRepeatVisibility">
<b-icon :icon="passwordVisible ? 'eye' : 'eye-slash'" /> <b-icon :icon="passwordVisibleRepeat ? 'eye' : 'eye-slash'" />
</b-button> </b-button>
</b-input-group-append> </b-input-group-append>
</b-input-group> </b-input-group>
</b-form-group> </b-form-group>
<base-input
:label="$t('form.passwordRepeat')"
type="password"
name="password-repeat"
:placeholder="$t('form.passwordRepeat')"
prepend-icon="ni ni-lock-circle-open"
v-model.lazy="checkPassword"
:class="{ valid: passwordValidation.valid }"
/>
<transition name="hint" appear> <transition name="hint" appear>
<div v-if="passwordValidation.errors.length > 0 && !submitted" class="hints"> <div v-if="passwordValidation.errors.length > 0 && !submitted" class="hints">
<ul> <ul>
@ -90,8 +115,11 @@ export default {
name: 'reset', name: 'reset',
data() { data() {
return { return {
form: {
password: '',
passwordRepeat: '',
},
password: '', password: '',
checkPassword: '',
passwordVisible: false, passwordVisible: false,
submitted: false, submitted: false,
authenticated: false, authenticated: false,
@ -100,13 +128,16 @@ export default {
} }
}, },
methods: { methods: {
getValidationState({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null
},
togglePasswordVisibility() { togglePasswordVisibility() {
this.passwordVisible = !this.passwordVisible this.passwordVisible = !this.passwordVisible
}, },
async onSubmit() { async onSubmit() {
const result = await loginAPI.changePassword(this.sessionId, this.email, this.password) const result = await loginAPI.changePassword(this.sessionId, this.email, this.form.password)
if (result.success) { if (result.success) {
this.password = '' this.form.password = ''
/* /*
this.$store.dispatch('login', { this.$store.dispatch('login', {
sessionId: result.result.data.session_id, sessionId: result.result.data.session_id,
@ -132,10 +163,10 @@ export default {
}, },
computed: { computed: {
samePasswords() { samePasswords() {
return this.password === this.checkPassword return this.form.password === this.form.passwordRepeat
}, },
passwordsFilled() { passwordsFilled() {
return this.password !== '' && this.checkPassword !== '' return this.form.password !== '' && this.form.passwordRepeat !== ''
}, },
rules() { rules() {
return [ return [
@ -148,7 +179,7 @@ export default {
passwordValidation() { passwordValidation() {
const errors = [] const errors = []
for (const condition of this.rules) { for (const condition of this.rules) {
if (!condition.regex.test(this.password)) { if (!condition.regex.test(this.form.password)) {
errors.push(condition.message) errors.push(condition.message)
} }
} }