rudeshark.net/src/client/app/common/views/components/password-settings.vue

50 lines
1.1 KiB
Vue
Raw Normal View History

2018-02-21 17:25:57 +01:00
<template>
<div>
<ui-button @click="reset">{{ $t('reset') }}</ui-button>
2018-02-21 17:25:57 +01:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
2018-02-21 17:25:57 +01:00
export default Vue.extend({
i18n: i18n('common/views/components/password-settings.vue'),
2018-02-21 17:25:57 +01:00
methods: {
reset() {
2018-11-09 00:26:32 +01:00
this.$root.apis.input({
title: this.$t('enter-current-password'),
2018-02-21 17:25:57 +01:00
type: 'password'
}).then(currentPassword => {
2018-11-09 00:26:32 +01:00
this.$root.apis.input({
title: this.$t('enter-new-password'),
2018-02-21 17:25:57 +01:00
type: 'password'
}).then(newPassword => {
2018-11-09 00:26:32 +01:00
this.$root.apis.input({
title: this.$t('enter-new-password-again'),
2018-02-21 17:25:57 +01:00
type: 'password'
}).then(newPassword2 => {
if (newPassword !== newPassword2) {
2018-11-09 00:26:32 +01:00
this.$root.apis.dialog({
2018-02-21 17:25:57 +01:00
title: null,
text: this.$t('not-match'),
2018-02-21 17:25:57 +01:00
actions: [{
text: 'OK'
}]
});
return;
}
2018-11-09 00:13:34 +01:00
this.$root.api('i/change_password', {
2018-03-29 07:48:47 +02:00
currentPasword: currentPassword,
newPassword: newPassword
2018-02-21 17:25:57 +01:00
}).then(() => {
2018-11-09 00:26:32 +01:00
this.$root.apis.notify(this.$t('changed'));
2018-02-21 17:25:57 +01:00
});
});
});
});
}
}
});
</script>