2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2020-01-30 04:10:42 +02:00
|
|
|
<section class="_card">
|
2020-01-29 21:37:25 +02:00
|
|
|
<div class="_title"><fa :icon="faLock"/> {{ $t('password') }}</div>
|
|
|
|
<div class="_content">
|
2020-07-24 19:36:39 +03:00
|
|
|
<mk-button primary @click="change()" v-t="'changePassword'"></mk-button>
|
2020-01-29 21:37:25 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faLock } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkButton from '../../components/ui/button.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
faLock
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async change() {
|
|
|
|
const { canceled: canceled1, result: currentPassword } = await this.$root.dialog({
|
|
|
|
title: this.$t('currentPassword'),
|
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
|
|
|
const { canceled: canceled2, result: newPassword } = await this.$root.dialog({
|
|
|
|
title: this.$t('newPassword'),
|
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
|
|
|
const { canceled: canceled3, result: newPassword2 } = await this.$root.dialog({
|
|
|
|
title: this.$t('newPasswordRetype'),
|
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled3) return;
|
|
|
|
|
|
|
|
if (newPassword !== newPassword2) {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: this.$t('retypedNotMatch')
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const dialog = this.$root.dialog({
|
|
|
|
type: 'waiting',
|
|
|
|
iconOnly: true
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$root.api('i/change-password', {
|
|
|
|
currentPassword,
|
|
|
|
newPassword
|
|
|
|
}).then(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
iconOnly: true, autoClose: true
|
|
|
|
});
|
|
|
|
}).catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});
|
|
|
|
}).finally(() => {
|
|
|
|
dialog.close();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|