Sharkey/packages/frontend/src/components/MkForgotPassword.vue

82 lines
1.9 KiB
Vue
Raw Normal View History

<template>
2023-01-06 02:41:14 +02:00
<MkModalWindow
2023-01-05 14:04:56 +02:00
ref="dialog"
:width="370"
:height="400"
@close="dialog.close()"
@closed="emit('closed')"
>
<template #header>{{ i18n.ts.forgotPassword }}</template>
<form v-if="instance.enableEmail" class="bafeceda" @submit.prevent="onSubmit">
2023-01-06 06:40:17 +02:00
<div class="main _gaps_m">
2023-01-05 14:04:56 +02:00
<MkInput v-model="username" type="text" pattern="^[a-zA-Z0-9_]+$" :spellcheck="false" autofocus required>
<template #label>{{ i18n.ts.username }}</template>
<template #prefix>@</template>
</MkInput>
2023-01-05 14:04:56 +02:00
<MkInput v-model="email" type="email" :spellcheck="false" required>
<template #label>{{ i18n.ts.emailAddress }}</template>
<template #caption>{{ i18n.ts._forgotPassword.enterEmail }}</template>
</MkInput>
2023-01-05 14:04:56 +02:00
<MkButton type="submit" :disabled="processing" primary style="margin: 0 auto;">{{ i18n.ts.send }}</MkButton>
</div>
2021-10-31 12:19:28 +02:00
<div class="sub">
<MkA to="/about" class="_link">{{ i18n.ts._forgotPassword.ifNoEmail }}</MkA>
</div>
</form>
<div v-else class="bafecedb">
{{ i18n.ts._forgotPassword.contactAdmin }}
</div>
2023-01-06 02:41:14 +02:00
</MkModalWindow>
</template>
<script lang="ts" setup>
import { } from 'vue';
2023-01-06 02:41:14 +02:00
import MkModalWindow from '@/components/MkModalWindow.vue';
import MkButton from '@/components/MkButton.vue';
2023-01-07 08:09:46 +02:00
import MkInput from '@/components/MkInput.vue';
2021-11-11 19:02:25 +02:00
import * as os from '@/os';
import { instance } from '@/instance';
import { i18n } from '@/i18n';
const emit = defineEmits<{
(ev: 'done'): void;
(ev: 'closed'): void;
}>();
2023-01-06 02:41:14 +02:00
let dialog: InstanceType<typeof MkModalWindow> = $ref();
let username = $ref('');
let email = $ref('');
let processing = $ref(false);
async function onSubmit() {
processing = true;
await os.apiWithDialog('request-reset-password', {
username,
email,
});
emit('done');
dialog.close();
}
</script>
2021-10-31 12:19:28 +02:00
<style lang="scss" scoped>
2021-10-31 12:19:28 +02:00
.bafeceda {
> .main {
padding: 24px;
}
> .sub {
border-top: solid 0.5px var(--divider);
padding: 24px;
}
}
.bafecedb {
padding: 24px;
}
2021-10-31 12:19:28 +02:00
</style>