mirror of https://github.com/nocodb/nocodb
144 lines
4.3 KiB
144 lines
4.3 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { definePageMeta, extractSdkResponseErrorMsg, isEmail, reactive, ref, useApi, useI18n } from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
const { api, isLoading } = useApi()
|
||
2 years ago
|
|
||
|
const { t } = useI18n()
|
||
|
|
||
|
definePageMeta({
|
||
|
requiresAuth: false,
|
||
2 years ago
|
title: 'title.resetPassword',
|
||
2 years ago
|
})
|
||
|
|
||
|
let error = $ref<string | null>(null)
|
||
2 years ago
|
|
||
2 years ago
|
let success = $ref(false)
|
||
2 years ago
|
|
||
|
const formValidator = ref()
|
||
|
|
||
|
const form = reactive({
|
||
|
email: '',
|
||
|
})
|
||
|
|
||
|
const formRules = {
|
||
|
email: [
|
||
|
// E-mail is required
|
||
2 years ago
|
{ required: true, message: t('msg.error.signUpRules.emailReqd') },
|
||
2 years ago
|
// E-mail must be valid format
|
||
2 years ago
|
{
|
||
|
validator: (_: unknown, v: string) => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
if (isEmail(v)) return resolve(true)
|
||
|
reject(new Error(t('msg.error.signUpRules.emailInvalid')))
|
||
|
})
|
||
|
},
|
||
|
message: t('msg.error.signUpRules.emailInvalid'),
|
||
|
},
|
||
2 years ago
|
],
|
||
|
}
|
||
|
|
||
2 years ago
|
async function resetPassword() {
|
||
|
if (!formValidator.value.validate()) return
|
||
|
|
||
|
resetError()
|
||
2 years ago
|
|
||
2 years ago
|
try {
|
||
2 years ago
|
await api.auth.passwordForgot(form)
|
||
|
|
||
2 years ago
|
success = true
|
||
2 years ago
|
} catch (e: any) {
|
||
|
// todo: errors should not expose what was wrong (i.e. do not show "Password is wrong" messages)
|
||
|
error = await extractSdkResponseErrorMsg(e)
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
function resetError() {
|
||
|
if (error) error = null
|
||
2 years ago
|
}
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<NuxtLayout>
|
||
2 years ago
|
<div class="md:bg-primary bg-opacity-5 forgot-password h-full min-h-[600px] flex flex-col justify-center items-center">
|
||
2 years ago
|
<div
|
||
|
class="bg-white mt-[60px] relative flex flex-col justify-center gap-2 w-full max-w-[500px] mx-auto p-8 md:(rounded-lg border-1 border-gray-200 shadow-xl)"
|
||
|
>
|
||
2 years ago
|
<general-noco-icon class="color-transition hover:(ring ring-accent)" :class="[isLoading ? 'animated-bg-gradient' : '']" />
|
||
2 years ago
|
|
||
|
<div class="self-center flex flex-col justify-center items-center text-center gap-2">
|
||
|
<h1 class="prose-2xl font-bold my-4 w-full">{{ $t('title.resetPassword') }}</h1>
|
||
|
|
||
|
<template v-if="!success">
|
||
|
<div class="prose-sm">{{ $t('msg.info.passwordRecovery.message_1') }}</div>
|
||
|
<div class="prose-sm mb-4">{{ $t('msg.info.passwordRecovery.message_2') }}</div>
|
||
|
</template>
|
||
|
|
||
|
<template v-else>
|
||
|
<div class="prose-sm text-success flex items-center leading-8 gap-2">
|
||
|
{{ $t('msg.info.passwordRecovery.success') }} <ClaritySuccessLine />
|
||
|
</div>
|
||
2 years ago
|
|
||
2 years ago
|
<nuxt-link to="/signin">{{ $t('general.signIn') }}</nuxt-link>
|
||
|
</template>
|
||
|
</div>
|
||
2 years ago
|
|
||
2 years ago
|
<a-form ref="formValidator" layout="vertical" :model="form" no-style @finish="resetPassword">
|
||
2 years ago
|
<Transition name="layout">
|
||
2 years ago
|
<div v-if="error" class="self-center mb-4 bg-red-500 text-white rounded-lg w-3/4 mx-auto p-1">
|
||
|
<div class="flex items-center gap-2 justify-center">
|
||
|
<MaterialSymbolsWarning />
|
||
2 years ago
|
<div class="break-words">{{ error }}</div>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</Transition>
|
||
|
|
||
2 years ago
|
<a-form-item :label="$t('labels.email')" name="email" :rules="formRules.email">
|
||
2 years ago
|
<a-input v-model:value="form.email" size="large" :placeholder="$t('msg.info.signUp.workEmail')" @focus="resetError" />
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
|
||
2 years ago
|
<div class="self-center flex flex-col gap-4 items-center justify-center w-full">
|
||
2 years ago
|
<button class="submit" type="submit">
|
||
2 years ago
|
<span class="flex items-center gap-2">
|
||
|
<MdiLogin />
|
||
|
{{ $t('activity.sendEmail') }}
|
||
|
</span>
|
||
2 years ago
|
</button>
|
||
2 years ago
|
|
||
2 years ago
|
<div class="text-end prose-sm">
|
||
|
{{ $t('msg.info.signUp.alreadyHaveAccount') }}
|
||
2 years ago
|
<nuxt-link to="/signin">{{ $t('general.signIn') }}</nuxt-link>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
2 years ago
|
</a-form>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</NuxtLayout>
|
||
|
</template>
|
||
2 years ago
|
|
||
|
<style lang="scss">
|
||
|
.forgot-password {
|
||
|
.ant-input-affix-wrapper,
|
||
|
.ant-input {
|
||
2 years ago
|
@apply !appearance-none my-1 border-1 border-solid border-primary/50 rounded;
|
||
2 years ago
|
}
|
||
|
|
||
|
.submit {
|
||
2 years ago
|
@apply z-1 relative color-transition rounded p-3 text-white shadow;
|
||
2 years ago
|
|
||
|
&::after {
|
||
2 years ago
|
@apply rounded absolute top-0 left-0 right-0 bottom-0 transition-all duration-150 ease-in-out bg-primary;
|
||
2 years ago
|
content: '';
|
||
|
z-index: -1;
|
||
|
}
|
||
|
|
||
|
&:hover::after {
|
||
2 years ago
|
@apply transform scale-110 ring ring-accent;
|
||
2 years ago
|
}
|
||
|
|
||
|
&:active::after {
|
||
2 years ago
|
@apply ring ring-accent;
|
||
2 years ago
|
}
|
||
2 years ago
|
}
|
||
|
}
|
||
|
</style>
|