2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2023-01-06 06:40:17 +02:00
|
|
|
<div class="_gaps_m">
|
2023-01-06 02:56:33 +02:00
|
|
|
<FormSection first>
|
2022-05-04 04:10:34 +03:00
|
|
|
<template #label>{{ i18n.ts.password }}</template>
|
2023-01-06 02:41:14 +02:00
|
|
|
<MkButton primary @click="change()">{{ i18n.ts.changePassword }}</MkButton>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSection>
|
|
|
|
|
2023-02-20 09:40:24 +02:00
|
|
|
<X2fa/>
|
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSection>
|
2022-05-04 04:10:34 +03:00
|
|
|
<template #label>{{ i18n.ts.signinHistory }}</template>
|
2022-07-14 17:50:07 +03:00
|
|
|
<MkPagination :pagination="pagination" disable-auto-load>
|
2022-06-20 11:38:49 +03:00
|
|
|
<template #default="{items}">
|
2021-11-28 13:07:37 +02:00
|
|
|
<div>
|
|
|
|
<div v-for="item in items" :key="item.id" v-panel class="timnmucd">
|
|
|
|
<header>
|
2022-12-19 12:01:30 +02:00
|
|
|
<i v-if="item.success" class="ti ti-check icon succ"></i>
|
|
|
|
<i v-else class="ti ti-circle-x icon fail"></i>
|
2021-11-28 13:07:37 +02:00
|
|
|
<code class="ip _monospace">{{ item.ip }}</code>
|
|
|
|
<MkTime :time="item.createdAt" class="time"/>
|
|
|
|
</header>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-01-09 14:35:35 +02:00
|
|
|
</MkPagination>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<FormSlot>
|
2023-01-06 02:41:14 +02:00
|
|
|
<MkButton danger @click="regenerateToken"><i class="ti ti-refresh"></i> {{ i18n.ts.regenerateLoginToken }}</MkButton>
|
2022-05-04 04:10:34 +03:00
|
|
|
<template #caption>{{ i18n.ts.regenerateLoginTokenDescription }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormSlot>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 04:10:34 +03:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 11:38:49 +03:00
|
|
|
import X2fa from './2fa.vue';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
2023-01-06 02:41:14 +02:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-09-06 12:21:49 +03:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
2022-05-04 04:10:34 +03:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 11:38:49 +03:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-05-04 04:10:34 +03:00
|
|
|
|
|
|
|
const pagination = {
|
|
|
|
endpoint: 'i/signin-history' as const,
|
|
|
|
limit: 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
async function change() {
|
|
|
|
const { canceled: canceled1, result: currentPassword } = await os.inputText({
|
|
|
|
title: i18n.ts.currentPassword,
|
2022-06-20 11:38:49 +03:00
|
|
|
type: 'password',
|
2023-02-20 09:40:24 +02:00
|
|
|
autocomplete: 'current-password',
|
2022-05-04 04:10:34 +03:00
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
|
|
|
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
|
|
|
title: i18n.ts.newPassword,
|
2022-06-20 11:38:49 +03:00
|
|
|
type: 'password',
|
2023-02-20 09:40:24 +02:00
|
|
|
autocomplete: 'new-password',
|
2022-05-04 04:10:34 +03:00
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
|
|
|
const { canceled: canceled3, result: newPassword2 } = await os.inputText({
|
|
|
|
title: i18n.ts.newPasswordRetype,
|
2022-06-20 11:38:49 +03:00
|
|
|
type: 'password',
|
2023-02-20 09:40:24 +02:00
|
|
|
autocomplete: 'new-password',
|
2022-05-04 04:10:34 +03:00
|
|
|
});
|
|
|
|
if (canceled3) return;
|
|
|
|
|
|
|
|
if (newPassword !== newPassword2) {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
2022-06-20 11:38:49 +03:00
|
|
|
text: i18n.ts.retypedNotMatch,
|
2022-05-04 04:10:34 +03:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-05-04 04:10:34 +03:00
|
|
|
os.apiWithDialog('i/change-password', {
|
|
|
|
currentPassword,
|
2022-06-20 11:38:49 +03:00
|
|
|
newPassword,
|
2022-05-04 04:10:34 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function regenerateToken() {
|
|
|
|
os.inputText({
|
|
|
|
title: i18n.ts.password,
|
2022-06-20 11:38:49 +03:00
|
|
|
type: 'password',
|
2022-05-04 04:10:34 +03:00
|
|
|
}).then(({ canceled, result: password }) => {
|
|
|
|
if (canceled) return;
|
2023-02-08 13:12:44 +02:00
|
|
|
os.api('i/regenerate-token', {
|
2022-06-20 11:38:49 +03:00
|
|
|
password: password,
|
2022-05-04 04:10:34 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 11:38:49 +03:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.security,
|
2022-12-19 12:01:30 +02:00
|
|
|
icon: 'ti ti-lock',
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
|
|
|
</script>
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2022-12-27 11:29:39 +02:00
|
|
|
<style lang="scss" scoped>
|
2020-11-25 14:31:34 +02:00
|
|
|
.timnmucd {
|
2023-02-20 09:40:24 +02:00
|
|
|
padding: 12px;
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
&:first-child {
|
|
|
|
border-top-left-radius: 6px;
|
|
|
|
border-top-right-radius: 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
border-bottom-left-radius: 6px;
|
|
|
|
border-bottom-right-radius: 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
border-bottom: solid 0.5px var(--divider);
|
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
width: 1em;
|
|
|
|
margin-right: 0.75em;
|
|
|
|
|
|
|
|
&.succ {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.fail {
|
|
|
|
color: var(--error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-12 05:12:01 +02:00
|
|
|
> .ip {
|
2020-12-12 05:13:27 +02:00
|
|
|
flex: 1;
|
2020-12-12 05:12:01 +02:00
|
|
|
min-width: 0;
|
|
|
|
white-space: nowrap;
|
2021-03-02 15:57:16 +02:00
|
|
|
overflow: hidden;
|
2020-12-12 05:12:01 +02:00
|
|
|
text-overflow: ellipsis;
|
2020-12-12 05:13:27 +02:00
|
|
|
margin-right: 12px;
|
2020-12-12 05:12:01 +02:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
> .time {
|
|
|
|
margin-left: auto;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|