2020-10-17 06:12:00 -05:00
|
|
|
<template>
|
2021-11-28 05:07:37 -06:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSection>
|
2022-05-03 20:10:34 -05:00
|
|
|
<template #label>{{ i18n.ts.password }}</template>
|
|
|
|
<FormButton primary @click="change()">{{ i18n.ts.changePassword }}</FormButton>
|
2021-11-28 05:07:37 -06:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
2022-05-03 20:10:34 -05:00
|
|
|
<template #label>{{ i18n.ts.twoStepAuthentication }}</template>
|
2021-11-28 05:07:37 -06:00
|
|
|
<X2fa/>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
2022-05-03 20:10:34 -05:00
|
|
|
<template #label>{{ i18n.ts.signinHistory }}</template>
|
2022-01-09 06:35:35 -06:00
|
|
|
<MkPagination :pagination="pagination">
|
2021-12-02 05:09:12 -06:00
|
|
|
<template v-slot="{items}">
|
2021-11-28 05:07:37 -06:00
|
|
|
<div>
|
|
|
|
<div v-for="item in items" :key="item.id" v-panel class="timnmucd">
|
|
|
|
<header>
|
|
|
|
<i v-if="item.success" class="fas fa-check icon succ"></i>
|
|
|
|
<i v-else class="fas fa-times-circle icon fail"></i>
|
|
|
|
<code class="ip _monospace">{{ item.ip }}</code>
|
|
|
|
<MkTime :time="item.createdAt" class="time"/>
|
|
|
|
</header>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-01-09 06:35:35 -06:00
|
|
|
</MkPagination>
|
2021-11-28 05:07:37 -06:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<FormSlot>
|
2022-05-03 20:10:34 -05:00
|
|
|
<FormButton danger @click="regenerateToken"><i class="fas fa-sync-alt"></i> {{ i18n.ts.regenerateLoginToken }}</FormButton>
|
|
|
|
<template #caption>{{ i18n.ts.regenerateLoginTokenDescription }}</template>
|
2021-11-28 05:07:37 -06:00
|
|
|
</FormSlot>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</template>
|
|
|
|
|
2022-05-03 20:10:34 -05:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineExpose } from 'vue';
|
2021-11-28 05:07:37 -06:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
2022-01-09 06:35:35 -06:00
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
2021-11-28 05:07:37 -06:00
|
|
|
import X2fa from './2fa.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2022-05-03 20:10:34 -05:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
|
|
|
|
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,
|
|
|
|
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;
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2022-05-03 20:10:34 -05:00
|
|
|
os.apiWithDialog('i/change-password', {
|
|
|
|
currentPassword,
|
|
|
|
newPassword
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function regenerateToken() {
|
|
|
|
os.inputText({
|
|
|
|
title: i18n.ts.password,
|
|
|
|
type: 'password'
|
|
|
|
}).then(({ canceled, result: password }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
os.api('i/regenerate_token', {
|
|
|
|
password: password
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
[symbols.PAGE_INFO]: {
|
|
|
|
title: i18n.ts.security,
|
|
|
|
icon: 'fas fa-lock',
|
|
|
|
bg: 'var(--bg)',
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-11-25 06:31:34 -06:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.timnmucd {
|
|
|
|
padding: 16px;
|
|
|
|
|
2021-11-28 05:07:37 -06: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 06:31:34 -06:00
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
width: 1em;
|
|
|
|
margin-right: 0.75em;
|
|
|
|
|
|
|
|
&.succ {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.fail {
|
|
|
|
color: var(--error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-11 21:12:01 -06:00
|
|
|
> .ip {
|
2020-12-11 21:13:27 -06:00
|
|
|
flex: 1;
|
2020-12-11 21:12:01 -06:00
|
|
|
min-width: 0;
|
|
|
|
white-space: nowrap;
|
2021-03-02 07:57:16 -06:00
|
|
|
overflow: hidden;
|
2020-12-11 21:12:01 -06:00
|
|
|
text-overflow: ellipsis;
|
2020-12-11 21:13:27 -06:00
|
|
|
margin-right: 12px;
|
2020-12-11 21:12:01 -06:00
|
|
|
}
|
|
|
|
|
2020-11-25 06:31:34 -06:00
|
|
|
> .time {
|
|
|
|
margin-left: auto;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|