mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 08:13:07 +02:00
refactor(client): refactor settings/security to use Composition API (#8592)
This commit is contained in:
parent
1f222e6cd1
commit
f8c66be130
1 changed files with 61 additions and 75 deletions
|
@ -1,17 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot">
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.password }}</template>
|
<template #label>{{ i18n.ts.password }}</template>
|
||||||
<FormButton primary @click="change()">{{ $ts.changePassword }}</FormButton>
|
<FormButton primary @click="change()">{{ i18n.ts.changePassword }}</FormButton>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.twoStepAuthentication }}</template>
|
<template #label>{{ i18n.ts.twoStepAuthentication }}</template>
|
||||||
<X2fa/>
|
<X2fa/>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>{{ $ts.signinHistory }}</template>
|
<template #label>{{ i18n.ts.signinHistory }}</template>
|
||||||
<MkPagination :pagination="pagination">
|
<MkPagination :pagination="pagination">
|
||||||
<template v-slot="{items}">
|
<template v-slot="{items}">
|
||||||
<div>
|
<div>
|
||||||
|
@ -30,15 +30,15 @@
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<FormSlot>
|
<FormSlot>
|
||||||
<FormButton danger @click="regenerateToken"><i class="fas fa-sync-alt"></i> {{ $ts.regenerateLoginToken }}</FormButton>
|
<FormButton danger @click="regenerateToken"><i class="fas fa-sync-alt"></i> {{ i18n.ts.regenerateLoginToken }}</FormButton>
|
||||||
<template #caption>{{ $ts.regenerateLoginTokenDescription }}</template>
|
<template #caption>{{ i18n.ts.regenerateLoginTokenDescription }}</template>
|
||||||
</FormSlot>
|
</FormSlot>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { defineExpose } from 'vue';
|
||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import FormSlot from '@/components/form/slot.vue';
|
import FormSlot from '@/components/form/slot.vue';
|
||||||
import FormButton from '@/components/ui/button.vue';
|
import FormButton from '@/components/ui/button.vue';
|
||||||
|
@ -46,77 +46,63 @@ import MkPagination from '@/components/ui/pagination.vue';
|
||||||
import X2fa from './2fa.vue';
|
import X2fa from './2fa.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const pagination = {
|
||||||
components: {
|
endpoint: 'i/signin-history' as const,
|
||||||
FormSection,
|
limit: 5,
|
||||||
FormButton,
|
};
|
||||||
MkPagination,
|
|
||||||
FormSlot,
|
async function change() {
|
||||||
X2fa,
|
const { canceled: canceled1, result: currentPassword } = await os.inputText({
|
||||||
},
|
title: i18n.ts.currentPassword,
|
||||||
|
type: 'password'
|
||||||
|
});
|
||||||
|
if (canceled1) return;
|
||||||
|
|
||||||
|
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
||||||
|
title: i18n.ts.newPassword,
|
||||||
|
type: 'password'
|
||||||
|
});
|
||||||
|
if (canceled2) return;
|
||||||
|
|
||||||
|
const { canceled: canceled3, result: newPassword2 } = await os.inputText({
|
||||||
|
title: i18n.ts.newPasswordRetype,
|
||||||
|
type: 'password'
|
||||||
|
});
|
||||||
|
if (canceled3) return;
|
||||||
|
|
||||||
|
if (newPassword !== newPassword2) {
|
||||||
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
text: i18n.ts.retypedNotMatch
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emits: ['info'],
|
os.apiWithDialog('i/change-password', {
|
||||||
|
currentPassword,
|
||||||
data() {
|
newPassword
|
||||||
return {
|
});
|
||||||
[symbols.PAGE_INFO]: {
|
}
|
||||||
title: this.$ts.security,
|
|
||||||
icon: 'fas fa-lock',
|
|
||||||
bg: 'var(--bg)',
|
|
||||||
},
|
|
||||||
pagination: {
|
|
||||||
endpoint: 'i/signin-history' as const,
|
|
||||||
limit: 5,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
function regenerateToken() {
|
||||||
async change() {
|
os.inputText({
|
||||||
const { canceled: canceled1, result: currentPassword } = await os.inputText({
|
title: i18n.ts.password,
|
||||||
title: this.$ts.currentPassword,
|
type: 'password'
|
||||||
type: 'password'
|
}).then(({ canceled, result: password }) => {
|
||||||
});
|
if (canceled) return;
|
||||||
if (canceled1) return;
|
os.api('i/regenerate_token', {
|
||||||
|
password: password
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
defineExpose({
|
||||||
title: this.$ts.newPassword,
|
[symbols.PAGE_INFO]: {
|
||||||
type: 'password'
|
title: i18n.ts.security,
|
||||||
});
|
icon: 'fas fa-lock',
|
||||||
if (canceled2) return;
|
bg: 'var(--bg)',
|
||||||
|
|
||||||
const { canceled: canceled3, result: newPassword2 } = await os.inputText({
|
|
||||||
title: this.$ts.newPasswordRetype,
|
|
||||||
type: 'password'
|
|
||||||
});
|
|
||||||
if (canceled3) return;
|
|
||||||
|
|
||||||
if (newPassword !== newPassword2) {
|
|
||||||
os.alert({
|
|
||||||
type: 'error',
|
|
||||||
text: this.$ts.retypedNotMatch
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
os.apiWithDialog('i/change-password', {
|
|
||||||
currentPassword,
|
|
||||||
newPassword
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
regenerateToken() {
|
|
||||||
os.inputText({
|
|
||||||
title: this.$ts.password,
|
|
||||||
type: 'password'
|
|
||||||
}).then(({ canceled, result: password }) => {
|
|
||||||
if (canceled) return;
|
|
||||||
os.api('i/regenerate_token', {
|
|
||||||
password: password
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue