2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2020-11-25 21:31:34 +09:00
|
|
|
<FormBase>
|
|
|
|
<X2fa/>
|
2020-12-26 10:47:36 +09:00
|
|
|
<FormLink to="/settings/2fa"><template #icon><Fa :icon="faMobileAlt"/></template>{{ $ts.twoStepAuthentication }}</FormLink>
|
|
|
|
<FormButton primary @click="change()">{{ $ts.changePassword }}</FormButton>
|
2020-11-25 21:31:34 +09:00
|
|
|
<FormPagination :pagination="pagination">
|
2020-12-26 10:47:36 +09:00
|
|
|
<template #label>{{ $ts.signinHistory }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
<template #default="{items}">
|
|
|
|
<div class="_formPanel timnmucd" v-for="item in items" :key="item.id">
|
|
|
|
<header>
|
|
|
|
<Fa class="icon succ" :icon="faCheck" v-if="item.success"/>
|
|
|
|
<Fa class="icon fail" :icon="faTimesCircle" v-else/>
|
|
|
|
<code class="ip _monospace">{{ item.ip }}</code>
|
|
|
|
<MkTime :time="item.createdAt" class="time"/>
|
|
|
|
</header>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</FormPagination>
|
|
|
|
<FormGroup>
|
2020-12-26 10:47:36 +09:00
|
|
|
<FormButton danger @click="regenerateToken"><Fa :icon="faSyncAlt"/> {{ $ts.regenerateLoginToken }}</FormButton>
|
|
|
|
<template #caption>{{ $ts.regenerateLoginTokenDescription }}</template>
|
2020-11-25 21:31:34 +09:00
|
|
|
</FormGroup>
|
|
|
|
</FormBase>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2020-11-25 21:31:34 +09:00
|
|
|
import { faCheck, faTimesCircle, faLock, faSyncAlt, faMobileAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import FormBase from '@/components/form/base.vue';
|
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormGroup from '@/components/form/group.vue';
|
|
|
|
import FormButton from '@/components/form/button.vue';
|
|
|
|
import FormPagination from '@/components/form/pagination.vue';
|
2020-10-17 20:12:00 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 21:31:34 +09:00
|
|
|
FormBase,
|
|
|
|
FormLink,
|
|
|
|
FormButton,
|
|
|
|
FormPagination,
|
|
|
|
FormGroup,
|
2020-10-17 20:12:00 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
INFO: {
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.security,
|
2020-11-03 20:36:12 +09:00
|
|
|
icon: faLock
|
2020-10-17 20:12:00 +09:00
|
|
|
},
|
2020-11-25 21:31:34 +09:00
|
|
|
pagination: {
|
|
|
|
endpoint: 'i/signin-history',
|
|
|
|
limit: 5,
|
|
|
|
},
|
|
|
|
faLock, faSyncAlt, faCheck, faTimesCircle, faMobileAlt,
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async change() {
|
|
|
|
const { canceled: canceled1, result: currentPassword } = await os.dialog({
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.currentPassword,
|
2020-10-17 20:12:00 +09:00
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled1) return;
|
|
|
|
|
|
|
|
const { canceled: canceled2, result: newPassword } = await os.dialog({
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.newPassword,
|
2020-10-17 20:12:00 +09:00
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled2) return;
|
|
|
|
|
|
|
|
const { canceled: canceled3, result: newPassword2 } = await os.dialog({
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.newPasswordRetype,
|
2020-10-17 20:12:00 +09:00
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled3) return;
|
|
|
|
|
|
|
|
if (newPassword !== newPassword2) {
|
|
|
|
os.dialog({
|
|
|
|
type: 'error',
|
2020-12-26 10:47:36 +09:00
|
|
|
text: this.$ts.retypedNotMatch
|
2020-10-17 20:12:00 +09:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os.apiWithDialog('i/change-password', {
|
|
|
|
currentPassword,
|
|
|
|
newPassword
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
regenerateToken() {
|
|
|
|
os.dialog({
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.password,
|
2020-10-17 20:12:00 +09:00
|
|
|
input: {
|
|
|
|
type: 'password'
|
|
|
|
}
|
|
|
|
}).then(({ canceled, result: password }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
os.api('i/regenerate_token', {
|
|
|
|
password: password
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-11-25 21:31:34 +09:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.timnmucd {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
width: 1em;
|
|
|
|
margin-right: 0.75em;
|
|
|
|
|
|
|
|
&.succ {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.fail {
|
|
|
|
color: var(--error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-12 12:12:01 +09:00
|
|
|
> .ip {
|
2020-12-12 12:13:27 +09:00
|
|
|
flex: 1;
|
2020-12-12 12:12:01 +09:00
|
|
|
min-width: 0;
|
|
|
|
white-space: nowrap;
|
2021-03-02 22:57:16 +09:00
|
|
|
overflow: hidden;
|
2020-12-12 12:12:01 +09:00
|
|
|
text-overflow: ellipsis;
|
2020-12-12 12:13:27 +09:00
|
|
|
margin-right: 12px;
|
2020-12-12 12:12:01 +09:00
|
|
|
}
|
|
|
|
|
2020-11-25 21:31:34 +09:00
|
|
|
> .time {
|
|
|
|
margin-left: auto;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|