egirlskey/packages/client/src/components/forgot-password.vue

81 lines
2 KiB
Vue
Raw Normal View History

<template>
<XModalWindow ref="dialog"
:width="370"
:height="400"
@close="dialog.close()"
@closed="emit('closed')"
>
<template #header>{{ i18n.locale.forgotPassword }}</template>
<form v-if="instance.enableEmail" class="bafeceda" @submit.prevent="onSubmit">
2021-10-31 10:19:28 +00:00
<div class="main _formRoot">
2021-11-19 10:36:12 +00:00
<MkInput v-model="username" class="_formBlock" type="text" pattern="^[a-zA-Z0-9_]+$" spellcheck="false" autofocus required>
<template #label>{{ i18n.locale.username }}</template>
<template #prefix>@</template>
</MkInput>
2021-11-19 10:36:12 +00:00
<MkInput v-model="email" class="_formBlock" type="email" spellcheck="false" required>
<template #label>{{ i18n.locale.emailAddress }}</template>
<template #caption>{{ i18n.locale._forgotPassword.enterEmail }}</template>
</MkInput>
<MkButton class="_formBlock" type="submit" :disabled="processing" primary style="margin: 0 auto;">{{ i18n.locale.send }}</MkButton>
</div>
2021-10-31 10:19:28 +00:00
<div class="sub">
<MkA to="/about" class="_link">{{ i18n.locale._forgotPassword.ifNoEmail }}</MkA>
</div>
</form>
<div v-else class="bafecedb">
{{ i18n.locale._forgotPassword.contactAdmin }}
</div>
</XModalWindow>
</template>
<script lang="ts" setup>
import { } from 'vue';
2021-11-11 17:02:25 +00:00
import XModalWindow from '@/components/ui/modal-window.vue';
import MkButton from '@/components/ui/button.vue';
import MkInput from '@/components/form/input.vue';
import * as os from '@/os';
import { instance } from '@/instance';
import { i18n } from '@/i18n';
const emit = defineEmits<{
(e: 'done'): void;
(e: 'closed'): void;
}>();
let dialog: InstanceType<typeof XModalWindow> = $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 10:19:28 +00:00
<style lang="scss" scoped>
.bafeceda {
> .main {
padding: 24px;
}
> .sub {
border-top: solid 0.5px var(--divider);
padding: 24px;
}
}
.bafecedb {
padding: 24px;
}
2021-10-31 10:19:28 +00:00
</style>