2020-10-17 06:12:00 -05:00
|
|
|
<template>
|
2021-11-28 05:07:37 -06:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ $ts.password }}</template>
|
|
|
|
<FormButton primary @click="change()">{{ $ts.changePassword }}</FormButton>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ $ts.twoStepAuthentication }}</template>
|
|
|
|
<X2fa/>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
2020-12-25 19:47:36 -06:00
|
|
|
<template #label>{{ $ts.signinHistory }}</template>
|
2021-11-28 05:07:37 -06:00
|
|
|
<FormPagination :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>
|
|
|
|
</FormPagination>
|
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<FormSlot>
|
|
|
|
<FormButton danger @click="regenerateToken"><i class="fas fa-sync-alt"></i> {{ $ts.regenerateLoginToken }}</FormButton>
|
|
|
|
<template #caption>{{ $ts.regenerateLoginTokenDescription }}</template>
|
|
|
|
</FormSlot>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-10-17 06:12:00 -05:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-11-28 05:07:37 -06:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import FormLink from '@/components/debobigego/link.vue';
|
2021-11-28 05:07:37 -06:00
|
|
|
import FormSlot from '@/components/form/slot.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
|
|
|
import FormPagination from '@/components/form/pagination.vue';
|
|
|
|
import X2fa from './2fa.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-10-17 06:12:00 -05:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2021-11-28 05:07:37 -06:00
|
|
|
FormSection,
|
2020-11-25 06:31:34 -06:00
|
|
|
FormLink,
|
|
|
|
FormButton,
|
|
|
|
FormPagination,
|
2021-11-28 05:07:37 -06:00
|
|
|
FormSlot,
|
|
|
|
X2fa,
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 22:54:12 -05:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.security,
|
2021-09-29 10:50:45 -05:00
|
|
|
icon: 'fas fa-lock',
|
|
|
|
bg: 'var(--bg)',
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
2020-11-25 06:31:34 -06:00
|
|
|
pagination: {
|
|
|
|
endpoint: 'i/signin-history',
|
|
|
|
limit: 5,
|
|
|
|
},
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-09 22:54:12 -05:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2020-10-17 06:12:00 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async change() {
|
2021-11-18 03:45:58 -06:00
|
|
|
const { canceled: canceled1, result: currentPassword } = await os.inputText({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.currentPassword,
|
2021-11-18 03:45:58 -06:00
|
|
|
type: 'password'
|
2020-10-17 06:12:00 -05:00
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
2021-11-18 03:45:58 -06:00
|
|
|
const { canceled: canceled2, result: newPassword } = await os.inputText({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.newPassword,
|
2021-11-18 03:45:58 -06:00
|
|
|
type: 'password'
|
2020-10-17 06:12:00 -05:00
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
2021-11-18 03:45:58 -06:00
|
|
|
const { canceled: canceled3, result: newPassword2 } = await os.inputText({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.newPasswordRetype,
|
2021-11-18 03:45:58 -06:00
|
|
|
type: 'password'
|
2020-10-17 06:12:00 -05:00
|
|
|
});
|
|
|
|
if (canceled3) return;
|
|
|
|
|
|
|
|
if (newPassword !== newPassword2) {
|
2021-11-18 03:45:58 -06:00
|
|
|
os.alert({
|
2020-10-17 06:12:00 -05:00
|
|
|
type: 'error',
|
2020-12-25 19:47:36 -06:00
|
|
|
text: this.$ts.retypedNotMatch
|
2020-10-17 06:12:00 -05:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os.apiWithDialog('i/change-password', {
|
|
|
|
currentPassword,
|
|
|
|
newPassword
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
regenerateToken() {
|
2021-11-18 03:45:58 -06:00
|
|
|
os.inputText({
|
2020-12-25 19:47:36 -06:00
|
|
|
title: this.$ts.password,
|
2021-11-18 03:45:58 -06:00
|
|
|
type: 'password'
|
2020-10-17 06:12:00 -05:00
|
|
|
}).then(({ canceled, result: password }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
os.api('i/regenerate_token', {
|
|
|
|
password: password
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</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>
|