diff --git a/src/components/user/Config.vue b/src/components/user/Config.vue index 159c1cf..95c275b 100644 --- a/src/components/user/Config.vue +++ b/src/components/user/Config.vue @@ -54,15 +54,17 @@ /> - + + + @@ -267,19 +269,27 @@ - + + + Speichern - - {{ error }} - + + {{ error ? error.value : null }} + @@ -342,10 +352,8 @@ export default { } return true }, - empty_password: () => { - return this.acceptedPassword !== null - ? true - : 'Password wurde nicht gesetzt' + empty_password: data => { + return !!data || 'Password wird bentögigt' } } }, @@ -373,21 +381,24 @@ export default { if (this.$refs.mail.validate()) { if (this.mail) user.mail = this.mail } - if (this.$refs.password.validate()) { + if (this.$refs.newPassword.validate()) { if (this.password) user.password = this.password + } else { + return } - if (this.$refs.acceptedPassword.validate()) { + console.log(this.$refs.acceptedPasswordTest.validate()) + if (this.$refs.acceptedPasswordTest.validate()) { this.saveConfig({ oldUsername: user.username, ...user, acceptedPassword: this.acceptedPassword }) + this.$refs.acceptedPassword.reset() } else { this.passError = 'Du musst dein Password eingeben' } this.password = null this.controlPassword = null - this.acceptedPassword = '' }, calcLifefime(time) { if (time < 60) return String(time) + 'Sekunden' diff --git a/src/store/modules/user.js b/src/store/modules/user.js index ec30774..f2727b6 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -6,7 +6,7 @@ const state = { creditList: [], loading: false, addLoading: false, - error: '', + error: null, days: [], messages: [], status: [], @@ -134,8 +134,12 @@ const mutations = { setAddLoading(state, value) { state.addLoading = value }, - setError(state, value) { - state.error = value + setError(state, {value, error}) { + //clearTimeout(state.error? state.error.timeout : null) + state.error = {value, error} + state.error.timeout = setTimeout(() => { + state.error = null + }, 6000) }, createDays(state, date) { let days = [] @@ -257,14 +261,15 @@ const actions = { { ...data }, { headers: { Token: rootState.login.user.accessToken } } ) + console.log(response.data) commit('setUser', response.data) - commit('setError', '') + commit('setError', {value: 'Daten gespeichert', error: false}) dispatch('getLifeTime', null, { root: true }) } catch (e) { if (e.response) { if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.data) { - commit('setError', e.response.data.error) + commit('setError', { value: e.response.data.error, error: true}) } } }