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