summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/components/settings.password.vue
blob: 39896daf67ce058d753b92c34ab1d9211d746576 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
<div>
	<button @click="reset" class="ui primary">%i18n:@reset%</button>
</div>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
	methods: {
		reset() {
			(this as any).apis.input({
				title: '%i18n:@enter-current-password%',
				type: 'password'
			}).then(currentPassword => {
				(this as any).apis.input({
					title: '%i18n:@enter-new-password%',
					type: 'password'
				}).then(newPassword => {
					(this as any).apis.input({
						title: '%i18n:@enter-new-password-again%',
						type: 'password'
					}).then(newPassword2 => {
						if (newPassword !== newPassword2) {
							(this as any).apis.dialog({
								title: null,
								text: '%i18n:@not-match%',
								actions: [{
									text: 'OK'
								}]
							});
							return;
						}
						(this as any).api('i/change_password', {
							currentPasword: currentPassword,
							newPassword: newPassword
						}).then(() => {
							(this as any).apis.notify('%i18n:@changed%');
						});
					});
				});
			});
		}
	}
});
</script>