misskey/packages/frontend/src/pages/reset-password.vue

61 lines
1.6 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
2023-05-19 07:20:53 +00:00
<MkSpacer v-if="token" :contentMax="700" :marginMin="16" :marginMax="32">
2023-01-06 04:40:17 +00:00
<div class="_gaps_m">
2023-01-07 06:09:46 +00:00
<MkInput v-model="password" type="password">
<template #prefix><i class="ti ti-lock"></i></template>
<template #label>{{ i18n.ts.newPassword }}</template>
2023-01-07 06:09:46 +00:00
</MkInput>
2023-01-06 00:41:14 +00:00
<MkButton primary @click="save">{{ i18n.ts.save }}</MkButton>
</div>
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { defineAsyncComponent, onMounted, ref, computed } from 'vue';
2023-01-07 06:09:46 +00:00
import MkInput from '@/components/MkInput.vue';
2023-01-06 00:41:14 +00:00
import MkButton from '@/components/MkButton.vue';
2023-09-19 07:37:43 +00:00
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { mainRouter } from '@/global/router/main.js';
const props = defineProps<{
token?: string;
}>();
const password = ref('');
async function save() {
await os.apiWithDialog('reset-password', {
token: props.token,
password: password.value,
});
mainRouter.push('/');
}
onMounted(() => {
if (props.token == null) {
os.popup(defineAsyncComponent(() => import('@/components/MkForgotPassword.vue')), {}, {}, 'closed');
mainRouter.push('/');
}
});
const headerActions = computed(() => []);
const headerTabs = computed(() => []);
definePageMetadata({
title: i18n.ts.resetPassword,
icon: 'ti ti-lock',
});
</script>