2018-02-21 16:25:57 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2018-11-08 18:44:35 +00:00
|
|
|
<ui-button @click="reset">{{ $t('reset') }}</ui-button>
|
2018-02-21 16:25:57 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 18:44:35 +00:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-21 16:25:57 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 18:44:35 +00:00
|
|
|
i18n: i18n('common/views/components/password-settings.vue'),
|
2018-02-21 16:25:57 +00:00
|
|
|
methods: {
|
2018-12-02 11:10:53 +00:00
|
|
|
async reset() {
|
|
|
|
const { canceled: canceled1, result: currentPassword } = await this.$root.dialog({
|
2018-11-08 18:44:35 +00:00
|
|
|
title: this.$t('enter-current-password'),
|
2018-12-02 11:10:53 +00:00
|
|
|
input: {
|
2018-02-21 16:25:57 +00:00
|
|
|
type: 'password'
|
2018-12-02 11:10:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
|
|
|
const { canceled: canceled2, result: newPassword } = await this.$root.dialog({
|
|
|
|
title: this.$t('enter-new-password'),
|
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
|
|
|
const { canceled: canceled3, result: newPassword2 } = await this.$root.dialog({
|
|
|
|
title: this.$t('enter-new-password-again'),
|
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled3) return;
|
|
|
|
|
|
|
|
if (newPassword !== newPassword2) {
|
|
|
|
this.$root.dialog({
|
|
|
|
title: null,
|
|
|
|
text: this.$t('not-match')
|
2018-02-21 16:25:57 +00:00
|
|
|
});
|
2018-12-02 11:10:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$root.api('i/change_password', {
|
2018-12-07 21:18:37 +00:00
|
|
|
currentPassword,
|
|
|
|
newPassword
|
2018-12-02 11:10:53 +00:00
|
|
|
}).then(() => {
|
2018-12-07 21:18:37 +00:00
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
text: this.$t('changed')
|
|
|
|
});
|
|
|
|
}).catch(() => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: this.$t('failed')
|
|
|
|
});
|
2018-02-21 16:25:57 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|