2018-02-12 08:48:01 -06:00
|
|
|
<template>
|
2018-02-21 10:25:57 -06:00
|
|
|
<div class="2fa">
|
2018-10-26 01:17:50 -05:00
|
|
|
<p style="margin-top:0;">%i18n:@intro%<a href="%i18n:@url%" target="_blank">%i18n:@detail%</a></p>
|
2018-10-25 18:37:30 -05:00
|
|
|
<ui-info warn>%i18n:@caution%</ui-info>
|
2018-10-18 16:18:33 -05:00
|
|
|
<p v-if="!data && !$store.state.i.twoFactorEnabled"><ui-button @click="register">%i18n:@register%</ui-button></p>
|
2018-05-26 23:49:09 -05:00
|
|
|
<template v-if="$store.state.i.twoFactorEnabled">
|
2018-04-14 11:04:40 -05:00
|
|
|
<p>%i18n:@already-registered%</p>
|
2018-10-18 16:18:33 -05:00
|
|
|
<ui-button @click="unregister">%i18n:@unregister%</ui-button>
|
2018-02-12 08:48:01 -06:00
|
|
|
</template>
|
|
|
|
<div v-if="data">
|
|
|
|
<ol>
|
2018-04-14 11:04:40 -05:00
|
|
|
<li>%i18n:@authenticator% <a href="https://support.google.com/accounts/answer/1066447" target="_blank">%i18n:@howtoinstall%</a></li>
|
|
|
|
<li>%i18n:@scan%<br><img :src="data.qr"></li>
|
|
|
|
<li>%i18n:@done%<br>
|
2018-02-12 08:48:01 -06:00
|
|
|
<input type="number" v-model="token" class="ui">
|
2018-10-18 16:18:33 -05:00
|
|
|
<ui-button primary @click="submit">%i18n:@submit%</ui-button>
|
2018-02-12 08:48:01 -06:00
|
|
|
</li>
|
|
|
|
</ol>
|
2018-11-05 10:40:11 -06:00
|
|
|
<div class="ui info"><p><fa icon="info-circle"/>%i18n:@info%</p></div>
|
2018-02-12 08:48:01 -06:00
|
|
|
</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 10:25:57 -06:00
|
|
|
(this as any).apis.input({
|
2018-05-20 06:26:38 -05:00
|
|
|
title: '%i18n:@enter-password%',
|
2018-02-21 10:25:57 -06:00
|
|
|
type: 'password'
|
|
|
|
}).then(password => {
|
2018-02-17 21:35:18 -06:00
|
|
|
(this as any).api('i/2fa/register', {
|
2018-02-12 08:48:01 -06:00
|
|
|
password: password
|
|
|
|
}).then(data => {
|
|
|
|
this.data = data;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
unregister() {
|
2018-02-21 10:25:57 -06:00
|
|
|
(this as any).apis.input({
|
2018-05-20 06:26:38 -05:00
|
|
|
title: '%i18n:@enter-password%',
|
2018-02-21 10:25:57 -06:00
|
|
|
type: 'password'
|
|
|
|
}).then(password => {
|
2018-02-17 21:35:18 -06:00
|
|
|
(this as any).api('i/2fa/unregister', {
|
2018-02-12 08:48:01 -06:00
|
|
|
password: password
|
|
|
|
}).then(() => {
|
2018-05-20 06:26:38 -05:00
|
|
|
(this as any).apis.notify('%i18n:@unregistered%');
|
2018-05-26 23:49:09 -05:00
|
|
|
this.$store.state.i.twoFactorEnabled = false;
|
2018-02-12 08:48:01 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
submit() {
|
2018-02-17 21:35:18 -06:00
|
|
|
(this as any).api('i/2fa/done', {
|
2018-02-12 08:48:01 -06:00
|
|
|
token: this.token
|
|
|
|
}).then(() => {
|
2018-05-20 06:26:38 -05:00
|
|
|
(this as any).apis.notify('%i18n:@success%');
|
2018-05-26 23:49:09 -05:00
|
|
|
this.$store.state.i.twoFactorEnabled = true;
|
2018-02-12 08:48:01 -06:00
|
|
|
}).catch(() => {
|
2018-05-20 06:26:38 -05:00
|
|
|
(this as any).apis.notify('%i18n:@failed%');
|
2018-02-12 08:48:01 -06:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|