This commit is contained in:
syuilo 2018-02-22 01:25:57 +09:00
parent a77ac7e651
commit 3d4fccef45
8 changed files with 78 additions and 66 deletions

View File

@ -17,6 +17,7 @@ import ellipsis from './ellipsis.vue';
import messaging from './messaging.vue';
import messagingRoom from './messaging-room.vue';
import urlPreview from './url-preview.vue';
import twitterSetting from './twitter-setting.vue';
Vue.component('mk-signin', signin);
Vue.component('mk-signup', signup);
@ -35,3 +36,4 @@ Vue.component('mk-ellipsis', ellipsis);
Vue.component('mk-messaging', messaging);
Vue.component('mk-messaging-room', messagingRoom);
Vue.component('mk-url-preview', urlPreview);
Vue.component('mk-twitter-setting', twitterSetting);

View File

@ -1,11 +0,0 @@
import * as riot from 'riot';
export default (title, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return (riot as any).mount(dialog, {
title: title,
type: 'password',
onOk: onOk,
onCancel: onCancel
});
};

View File

@ -1,37 +0,0 @@
<template>
<div>
<button @click="reset" class="ui primary">%i18n:desktop.tags.mk-password-setting.reset%</button>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import passwordDialog from '../../scripts/password-dialog';
import dialog from '../../scripts/dialog';
import notify from '../../scripts/notify';
export default Vue.extend({
methods: {
reset() {
passwordDialog('%i18n:desktop.tags.mk-password-setting.enter-current-password%', currentPassword => {
passwordDialog('%i18n:desktop.tags.mk-password-setting.enter-new-password%', newPassword => {
passwordDialog('%i18n:desktop.tags.mk-password-setting.enter-new-password-again%', newPassword2 => {
if (newPassword !== newPassword2) {
dialog(null, '%i18n:desktop.tags.mk-password-setting.not-match%', [{
text: 'OK'
}]);
return;
}
(this as any).api('i/change_password', {
current_password: currentPassword,
new_password: newPassword
}).then(() => {
notify('%i18n:desktop.tags.mk-password-setting.changed%');
});
});
});
});
}
}
});
</script>

View File

@ -1,16 +1,16 @@
<template>
<div class="mk-2fa-setting">
<div class="2fa">
<p>%i18n:desktop.tags.mk-2fa-setting.intro%<a href="%i18n:desktop.tags.mk-2fa-setting.url%" target="_blank">%i18n:desktop.tags.mk-2fa-setting.detail%</a></p>
<div class="ui info warn"><p>%fa:exclamation-triangle%%i18n:desktop.tags.mk-2fa-setting.caution%</p></div>
<p v-if="!data && !I.two_factor_enabled"><button @click="register" class="ui primary">%i18n:desktop.tags.mk-2fa-setting.register%</button></p>
<template v-if="I.two_factor_enabled">
<p v-if="!data && !os.i.two_factor_enabled"><button @click="register" class="ui primary">%i18n:desktop.tags.mk-2fa-setting.register%</button></p>
<template v-if="os.i.two_factor_enabled">
<p>%i18n:desktop.tags.mk-2fa-setting.already-registered%</p>
<button @click="unregister" class="ui">%i18n:desktop.tags.mk-2fa-setting.unregister%</button>
</template>
<div v-if="data">
<ol>
<li>%i18n:desktop.tags.mk-2fa-setting.authenticator% <a href="https://support.google.com/accounts/answer/1066447" target="_blank">%i18n:desktop.tags.mk-2fa-setting.howtoinstall%</a></li>
<li>%i18n:desktop.tags.mk-2fa-setting.scan%<br><img src={ data.qr }></li>
<li>%i18n:desktop.tags.mk-2fa-setting.scan%<br><img :src="data.qr"></li>
<li>%i18n:desktop.tags.mk-2fa-setting.done%<br>
<input type="number" v-model="token" class="ui">
<button @click="submit" class="ui primary">%i18n:desktop.tags.mk-2fa-setting.submit%</button>
@ -23,8 +23,6 @@
<script lang="ts">
import Vue from 'vue';
import passwordDialog from '../../scripts/password-dialog';
import notify from '../../scripts/notify';
export default Vue.extend({
data() {
@ -35,7 +33,10 @@ export default Vue.extend({
},
methods: {
register() {
passwordDialog('%i18n:desktop.tags.mk-2fa-setting.enter-password%', password => {
(this as any).apis.input({
title: '%i18n:desktop.tags.mk-2fa-setting.enter-password%',
type: 'password'
}).then(password => {
(this as any).api('i/2fa/register', {
password: password
}).then(data => {
@ -45,11 +46,14 @@ export default Vue.extend({
},
unregister() {
passwordDialog('%i18n:desktop.tags.mk-2fa-setting.enter-password%', password => {
(this as any).apis.input({
title: '%i18n:desktop.tags.mk-2fa-setting.enter-password%',
type: 'password'
}).then(password => {
(this as any).api('i/2fa/unregister', {
password: password
}).then(() => {
notify('%i18n:desktop.tags.mk-2fa-setting.unregistered%');
(this as any).apis.notify('%i18n:desktop.tags.mk-2fa-setting.unregistered%');
(this as any).os.i.two_factor_enabled = false;
});
});
@ -59,10 +63,10 @@ export default Vue.extend({
(this as any).api('i/2fa/done', {
token: this.token
}).then(() => {
notify('%i18n:desktop.tags.mk-2fa-setting.success%');
(this as any).apis.notify('%i18n:desktop.tags.mk-2fa-setting.success%');
(this as any).os.i.two_factor_enabled = true;
}).catch(() => {
notify('%i18n:desktop.tags.mk-2fa-setting.failed%');
(this as any).apis.notify('%i18n:desktop.tags.mk-2fa-setting.failed%');
});
}
}
@ -70,7 +74,7 @@ export default Vue.extend({
</script>
<style lang="stylus" scoped>
.mk-2fa-setting
.2fa
color #4a535a
</style>

View File

@ -1,5 +1,5 @@
<template>
<div class="mk-mute-setting">
<div>
<div class="none ui info" v-if="!fetching && users.length == 0">
<p>%fa:info-circle%%i18n:desktop.tags.mk-mute-setting.no-users%</p>
</div>
@ -18,7 +18,7 @@ export default Vue.extend({
data() {
return {
fetching: true,
users: null
users: []
};
},
mounted() {

View File

@ -0,0 +1,47 @@
<template>
<div>
<button @click="reset" class="ui primary">%i18n:desktop.tags.mk-password-setting.reset%</button>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
methods: {
reset() {
(this as any).apis.input({
title: '%i18n:desktop.tags.mk-password-setting.enter-current-password%',
type: 'password'
}).then(currentPassword => {
(this as any).apis.input({
title: '%i18n:desktop.tags.mk-password-setting.enter-new-password%',
type: 'password'
}).then(newPassword => {
(this as any).apis.input({
title: '%i18n:desktop.tags.mk-password-setting.enter-new-password-again%',
type: 'password'
}).then(newPassword2 => {
if (newPassword !== newPassword2) {
(this as any).apis.dialog({
title: null,
text: '%i18n:desktop.tags.mk-password-setting.not-match%',
actions: [{
text: 'OK'
}]
});
return;
}
(this as any).api('i/change_password', {
current_password: currentPassword,
new_password: newPassword
}).then(() => {
(this as any).apis.notify('%i18n:desktop.tags.mk-password-setting.changed%');
});
});
});
});
}
}
});
</script>

View File

@ -30,7 +30,7 @@
<section class="mute" v-show="page == 'mute'">
<h1>%i18n:desktop.tags.mk-settings.mute%</h1>
<mk-mute-setting/>
<x-mute/>
</section>
<section class="apps" v-show="page == 'apps'">
@ -45,12 +45,12 @@
<section class="password" v-show="page == 'security'">
<h1>%i18n:desktop.tags.mk-settings.password%</h1>
<mk-password-setting/>
<x-password/>
</section>
<section class="2fa" v-show="page == 'security'">
<h1>%i18n:desktop.tags.mk-settings.2fa%</h1>
<mk-2fa-setting/>
<x-2fa/>
</section>
<section class="signin" v-show="page == 'security'">
@ -74,10 +74,16 @@
<script lang="ts">
import Vue from 'vue';
import XProfile from './settings.profile.vue';
import XMute from './settings.mute.vue';
import XPassword from './settings.password.vue';
import X2fa from './settings.2fa.vue';
export default Vue.extend({
components: {
XProfile
XProfile,
XMute,
XPassword,
X2fa
},
data() {
return {

View File

@ -100,6 +100,7 @@ export default define({
> .ip
margin-right 4px
padding 0 4px
> b
margin-right 4px