setuo password component

This commit is contained in:
Moriz Wahl 2021-06-16 13:40:27 +02:00
parent ed3ee9da82
commit da28f1f364
4 changed files with 80 additions and 41 deletions

View File

@ -0,0 +1,63 @@
<template>
<validation-provider tag="div" :rules="rules" :name="name" v-slot="{ errors, valid, validated }">
<b-form-group :label="label" :label-for="labelFor">
<b-input-group>
<b-form-input
v-model="currentValue"
:id="labelFor"
:name="name"
:placeholder="placeholder"
:type="showPassword ? 'text' : 'password'"
:state="validated ? valid : false"
></b-form-input>
<b-input-group-append>
<b-button variant="outline-primary" @click="toggleShowPassword">
<b-icon :icon="showPassword ? 'eye' : 'eye-slash'" />
</b-button>
</b-input-group-append>
<b-form-invalid-feedback>
{{ errors[0] }}
</b-form-invalid-feedback>
</b-input-group>
</b-form-group>
</validation-provider>
</template>
<script>
export default {
name: 'InputPassword',
props: {
rules: {
default: () => {
required: true
},
},
name: { default: '' },
label: { default: 'Password' },
placeholder: { default: 'Password' },
model: { required: true, type: String },
},
data() {
return {
currentValue: '',
showPassword: false,
}
},
computed: {
labelFor() {
return this.name + '-input-field'
},
},
methods: {
toggleShowPassword() {
console.log('toggleShowPassword', this.placeholder)
this.showPassword = !this.showPassword
},
},
watch: {
currentValue(val) {
console.log('currentValue', val)
this.$emit('input', val)
},
},
}
</script>

View File

@ -64,7 +64,8 @@
"change_username_info": "Einmal gespeichert, kann der Username ncht mehr geändert werden!"
},
"error": {
"error":"Fehler"
"error":"Fehler",
"no-account": "Leider konnten wir keinen Account finden mit diesen Daten!"
},
"transaction":{
"show_all":"Alle <strong>{count}</strong> Transaktionen ansehen",

View File

@ -64,7 +64,8 @@
"change_username_info": "Once saved, the username cannot be changed again!"
},
"error": {
"error":"Error"
"error":"Error",
"no-account": "Unfortunately we could not find an account to the given data!"
},
"transaction":{
"show_all":"View all <strong>{count}</strong> transactions.",

View File

@ -46,52 +46,25 @@
</b-form-group>
</validation-provider>
<validation-provider
:name="$t('form.password')"
:rules="{ required: true }"
v-slot="validationContext"
>
<b-form-group
class="mb-5"
id="example-input-group-1"
:label="$t('form.password')"
label-for="example-input-1"
>
<b-input-group>
<b-form-input
id="input-pwd"
name="input-pwd"
v-model="form.password"
:placeholder="$t('form.password')"
:type="passwordVisible ? 'text' : 'password'"
:state="getValidationState(validationContext)"
aria-describedby="input-2-live-feedback"
></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="input-2-live-feedback">
{{ validationContext.errors[0] }}
</b-form-invalid-feedback>
</b-form-group>
</validation-provider>
<input-password
name="password"
:label="$t('form.password')"
:placeholder="$t('form.password')"
model="form.password"
></input-password>
<b-alert v-show="loginfail" show dismissible variant="warning">
<span class="alert-text bv-example-row">
<b-row>
<b-col class="col-9 text-left text-dark">
<strong>
Leider konnten wir keinen Account finden mit diesen Daten!
{{ $t('error.no-account') }}
</strong>
</b-col>
</b-row>
</span>
</b-alert>
<div class="text-center">
<div class="text-center mt-4">
<b-button type="submit" variant="primary">{{ $t('login') }}</b-button>
</div>
</b-form>
@ -118,9 +91,13 @@
<script>
import loginAPI from '../../apis/loginAPI'
import CONFIG from '../../config'
import InputPassword from '../../components/Inputs/InputPassword'
export default {
name: 'login',
components: {
InputPassword,
},
data() {
return {
form: {
@ -137,12 +114,9 @@ export default {
getValidationState({ dirty, validated, valid = null }) {
return dirty || validated ? valid : null
},
togglePasswordVisibility() {
this.passwordVisible = !this.passwordVisible
},
async onSubmit() {
// error info ausschalten
console.log('submit', this.form.password)
this.loginfail = false
const loader = this.$loading.show({
container: this.$refs.submitButton,