2020-02-14 20:18:33 +02:00
|
|
|
<template>
|
|
|
|
<section class="_card">
|
|
|
|
<div class="_title"><fa :icon="faKey"/> API</div>
|
|
|
|
<div class="_content">
|
2020-07-18 06:12:10 +03:00
|
|
|
<mk-button @click="generateToken">{{ $t('generateAccessToken') }}</mk-button>
|
2020-02-14 20:18:33 +02:00
|
|
|
<mk-button @click="regenerateToken"><fa :icon="faSyncAlt"/> {{ $t('regenerate') }}</mk-button>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faKey, faSyncAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import MkButton from '../../components/ui/button.vue';
|
|
|
|
import MkInput from '../../components/ui/input.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
MkButton, MkInput
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
faKey, faSyncAlt
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2020-07-18 06:12:10 +03:00
|
|
|
async generateToken() {
|
|
|
|
this.$root.new(await import('../../components/token-generate-window.vue').then(m => m.default), {
|
|
|
|
}).$on('ok', async ({ name, permissions }) => {
|
|
|
|
const { token } = await this.$root.api('miauth/gen-token', {
|
|
|
|
session: null,
|
|
|
|
name: name,
|
|
|
|
permission: permissions,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
title: this.$t('token'),
|
|
|
|
text: token
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2020-02-14 20:18:33 +02:00
|
|
|
regenerateToken() {
|
|
|
|
this.$root.dialog({
|
|
|
|
title: this.$t('password'),
|
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
}).then(({ canceled, result: password }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
this.$root.api('i/regenerate_token', {
|
|
|
|
password: password
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|