2018-02-12 15:48:01 +01:00
|
|
|
<template>
|
2018-02-21 17:25:57 +01:00
|
|
|
<div class="2fa">
|
2018-02-12 15:48:01 +01:00
|
|
|
<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>
|
2018-03-25 17:19:07 +02:00
|
|
|
<p v-if="!data && !os.i.account.two_factor_enabled"><button @click="register" class="ui primary">%i18n:desktop.tags.mk-2fa-setting.register%</button></p>
|
|
|
|
<template v-if="os.i.account.two_factor_enabled">
|
2018-02-12 15:48:01 +01:00
|
|
|
<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>
|
2018-02-21 17:25:57 +01:00
|
|
|
<li>%i18n:desktop.tags.mk-2fa-setting.scan%<br><img :src="data.qr"></li>
|
2018-02-12 15:48:01 +01:00
|
|
|
<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>
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
<div class="ui info"><p>%fa:info-circle%%i18n:desktop.tags.mk-2fa-setting.info%</p></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
data: null,
|
|
|
|
token: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
register() {
|
2018-02-21 17:25:57 +01:00
|
|
|
(this as any).apis.input({
|
|
|
|
title: '%i18n:desktop.tags.mk-2fa-setting.enter-password%',
|
|
|
|
type: 'password'
|
|
|
|
}).then(password => {
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('i/2fa/register', {
|
2018-02-12 15:48:01 +01:00
|
|
|
password: password
|
|
|
|
}).then(data => {
|
|
|
|
this.data = data;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
unregister() {
|
2018-02-21 17:25:57 +01:00
|
|
|
(this as any).apis.input({
|
|
|
|
title: '%i18n:desktop.tags.mk-2fa-setting.enter-password%',
|
|
|
|
type: 'password'
|
|
|
|
}).then(password => {
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('i/2fa/unregister', {
|
2018-02-12 15:48:01 +01:00
|
|
|
password: password
|
|
|
|
}).then(() => {
|
2018-02-21 17:25:57 +01:00
|
|
|
(this as any).apis.notify('%i18n:desktop.tags.mk-2fa-setting.unregistered%');
|
2018-03-25 17:19:07 +02:00
|
|
|
(this as any).os.i.account.two_factor_enabled = false;
|
2018-02-12 15:48:01 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
submit() {
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).api('i/2fa/done', {
|
2018-02-12 15:48:01 +01:00
|
|
|
token: this.token
|
|
|
|
}).then(() => {
|
2018-02-21 17:25:57 +01:00
|
|
|
(this as any).apis.notify('%i18n:desktop.tags.mk-2fa-setting.success%');
|
2018-03-25 17:19:07 +02:00
|
|
|
(this as any).os.i.account.two_factor_enabled = true;
|
2018-02-12 15:48:01 +01:00
|
|
|
}).catch(() => {
|
2018-02-21 17:25:57 +01:00
|
|
|
(this as any).apis.notify('%i18n:desktop.tags.mk-2fa-setting.failed%');
|
2018-02-12 15:48:01 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-02-21 17:25:57 +01:00
|
|
|
.2fa
|
2018-02-12 15:48:01 +01:00
|
|
|
color #4a535a
|
|
|
|
|
|
|
|
</style>
|