Change Password Form

This commit is contained in:
Moriz Wahl 2021-06-15 14:18:07 +02:00
parent ed3ee9da82
commit 4d6bc21fb4
5 changed files with 28 additions and 19 deletions

View File

@ -34,7 +34,7 @@ const apiPost = async (url, payload) => {
return { success: true, result: result.error }
}
if (result.data.state !== 'success') {
throw new Error(result.data.msg)
throw new Error(result.data.errors)
}
return { success: true, result }
} catch (error) {
@ -113,8 +113,8 @@ const loginAPI = {
session_id: sessionId,
email,
update: {
'User.password': password,
'User.passwordNew': passwordNew,
'User.password_old': password,
'User.password': passwordNew,
},
}
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)

View File

@ -39,6 +39,7 @@
"password_new":"neues Passwort",
"password_new_repeat":"neues Passwort wiederholen",
"change": "ändern",
"change-password": "Passwort ändern",
"amount":"Betrag",
"memo":"Nachricht für den Empfänger",
"message":"Nachricht",
@ -64,7 +65,8 @@
"change_username_info": "Einmal gespeichert, kann der Username ncht mehr geändert werden!"
},
"error": {
"error":"Fehler"
"error":"Fehler",
"change-password": "Fehler beim Ändern des Passworts"
},
"transaction":{
"show_all":"Alle <strong>{count}</strong> Transaktionen ansehen",

View File

@ -39,6 +39,7 @@
"password_new":"New password",
"password_new_repeat":"Repeat new password",
"change": "change",
"change-password": "Change password",
"amount":"Amount",
"memo":"Message for the recipient",
"message":"Message",
@ -64,7 +65,8 @@
"change_username_info": "Once saved, the username cannot be changed again!"
},
"error": {
"error":"Error"
"error":"Error",
"change-password": "Error while changing password"
},
"transaction":{
"show_all":"View all <strong>{count}</strong> transactions.",

View File

@ -144,9 +144,6 @@ export default {
mounted() {
this.initScrollbar()
},
created() {
this.updateTransactions({ firstPage: 1, items: 5 })
},
}
</script>
<style lang="scss">

View File

@ -4,14 +4,14 @@
<b-form @keyup.prevent="loadSubmitButton">
<b-row class="mb-4 text-right">
<b-col class="text-right">
<a href="#change_pwd" v-if="edit_pwd" @click="edit_pwd = !edit_pwd">
<span>{{ $t('form.password') }} {{ $t('form.change') }}</span>
<a href="#change_pwd" v-if="!editPassword" @click="editPassword = !editPassword">
<span>{{ $t('form.change-password') }}</span>
<b-icon class="pointer ml-3" icon="pencil" />
</a>
<b-icon
v-else
@click="edit_pwd = !edit_pwd"
@click="cancelEdit()"
class="pointer"
icon="x-circle"
variant="danger"
@ -19,7 +19,7 @@
</b-col>
</b-row>
<div v-if="!edit_pwd">
<div v-if="editPassword">
<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>
@ -105,7 +105,7 @@
</b-col>
</b-row>
<b-row class="text-right" v-if="!edit_pwd">
<b-row class="text-right" v-if="editPassword">
<b-col>
<div class="text-right" ref="submitButton">
<b-button
@ -132,7 +132,7 @@ export default {
name: 'FormUserPasswort',
data() {
return {
edit_pwd: true,
editPassword: false,
email: null,
password: '',
passwordNew: '',
@ -144,6 +144,12 @@ export default {
}
},
methods: {
cancelEdit() {
this.editPassword = false
this.password = ''
this.passwordNew = ''
this.passwordNewRepeat = ''
},
togglePasswordVisibilityNewPwd() {
this.passwordVisibleNewPwd = !this.passwordVisibleNewPwd
},
@ -165,18 +171,20 @@ export default {
this.loading = true
}
},
async onSubmit() {
// console.log(this.data)
async onSubmit(event) {
event.preventDefault()
const result = await loginAPI.changePasswordProfile(
this.$store.state.sessionId,
this.email,
this.$store.state.email,
this.password,
this.passwordNew,
)
if (result.success) {
alert('changePassword success')
this.$toast.success(this.$t('site.thx.reset'))
this.cancelEdit()
} else {
alert(result.result.message)
this.$toast.error(this.$t('error.change-password'))
this.cancelEdit()
}
},
},