|
|
@ -14,7 +14,7 @@ definePageMeta({ |
|
|
|
requiresAuth: false, |
|
|
|
requiresAuth: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const valid = ref() |
|
|
|
const valid = $ref() |
|
|
|
let error = $ref<string | null>(null) |
|
|
|
let error = $ref<string | null>(null) |
|
|
|
|
|
|
|
|
|
|
|
const form = reactive({ |
|
|
|
const form = reactive({ |
|
|
@ -26,22 +26,42 @@ const form = reactive({ |
|
|
|
const formRules = { |
|
|
|
const formRules = { |
|
|
|
email: [ |
|
|
|
email: [ |
|
|
|
// E-mail is required |
|
|
|
// E-mail is required |
|
|
|
(v: string) => !!v || t('msg.error.signUpRules.emailReqd'), |
|
|
|
{ required: true, message: t('msg.error.signUpRules.emailReqd') }, |
|
|
|
// E-mail must be valid format |
|
|
|
// E-mail must be valid format |
|
|
|
(v: string) => isEmail(v) || t('msg.error.signUpRules.emailInvalid'), |
|
|
|
{ |
|
|
|
|
|
|
|
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'), |
|
|
|
|
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
password: [ |
|
|
|
password: [ |
|
|
|
// Password is required |
|
|
|
// Password is required |
|
|
|
(v: string) => !!v || t('msg.error.signUpRules.passwdRequired'), |
|
|
|
{ required: true, message: t('msg.error.signUpRules.passwdRequired') }, |
|
|
|
(v: string) => v.length >= 8 || t('msg.error.signUpRules.passwdLength'), |
|
|
|
{ min: 8, message: t('msg.error.signUpRules.passwdLength') }, |
|
|
|
], |
|
|
|
], |
|
|
|
passwordRepeat: [ |
|
|
|
passwordRepeat: [ |
|
|
|
|
|
|
|
// PasswordRepeat is required |
|
|
|
|
|
|
|
{ required: true, message: t('msg.error.signUpRules.passwdRequired') }, |
|
|
|
// Passwords match |
|
|
|
// Passwords match |
|
|
|
(v: string) => v === form.password || t('msg.error.signUpRules.passwdMismatch'), |
|
|
|
{ |
|
|
|
|
|
|
|
validator: (_: unknown, v: string) => { |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
if (form.password === form.passwordRepeat) return resolve(true) |
|
|
|
|
|
|
|
reject(new Error(t('msg.error.signUpRules.passwdMismatch'))) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
message: t('msg.error.signUpRules.passwdMismatch'), |
|
|
|
|
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const signUp = async () => { |
|
|
|
const signUp = async () => { |
|
|
|
|
|
|
|
if (!valid) return |
|
|
|
|
|
|
|
|
|
|
|
error = null |
|
|
|
error = null |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { token } = await $api.auth.signup(form) |
|
|
|
const { token } = await $api.auth.signup(form) |
|
|
@ -61,10 +81,13 @@ const resetError = () => { |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<NuxtLayout> |
|
|
|
<NuxtLayout> |
|
|
|
<v-form |
|
|
|
<a-form |
|
|
|
ref="formValidator" |
|
|
|
ref="formValidator" |
|
|
|
v-model="valid" |
|
|
|
:model="form" |
|
|
|
class="h-[calc(100%_+_90px)] min-h-[600px] flex justify-center items-center" |
|
|
|
layout="vertical" |
|
|
|
|
|
|
|
class="signup h-[calc(100%_+_90px)] min-h-[600px] flex justify-center items-center" |
|
|
|
|
|
|
|
@finish="valid = true" |
|
|
|
|
|
|
|
@finish-failed="valid = false" |
|
|
|
@submit.prevent="signUp" |
|
|
|
@submit.prevent="signUp" |
|
|
|
> |
|
|
|
> |
|
|
|
<div class="h-full w-full flex flex-col flex-wrap justify-center items-center"> |
|
|
|
<div class="h-full w-full flex flex-col flex-wrap justify-center items-center"> |
|
|
@ -81,53 +104,32 @@ const resetError = () => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Transition> |
|
|
|
</Transition> |
|
|
|
|
|
|
|
|
|
|
|
<v-text-field |
|
|
|
<a-form-item :label="$t('labels.email')" name="email" :rules="formRules.email"> |
|
|
|
id="email" |
|
|
|
<a-input v-model:value="form.email" size="large" :placeholder="$t('labels.email')" @focus="resetError" /> |
|
|
|
v-model="form.email" |
|
|
|
</a-form-item> |
|
|
|
class="bg-white dark:!bg-gray-900" |
|
|
|
|
|
|
|
:rules="formRules.email" |
|
|
|
<a-form-item :label="$t('labels.password')" name="password" :rules="formRules.password"> |
|
|
|
:label="$t('labels.email')" |
|
|
|
<a-input-password |
|
|
|
:placeholder="$t('labels.email')" |
|
|
|
v-model:value="form.password" |
|
|
|
:persistent-placeholder="true" |
|
|
|
size="large" |
|
|
|
type="text" |
|
|
|
class="password" |
|
|
|
@focus="resetError" |
|
|
|
:placeholder="$t('labels.password')" |
|
|
|
/> |
|
|
|
@focus="resetError" |
|
|
|
|
|
|
|
/> |
|
|
|
<v-text-field |
|
|
|
</a-form-item> |
|
|
|
id="password" |
|
|
|
|
|
|
|
v-model="form.password" |
|
|
|
<a-form-item :label="`Repeat ${$t('labels.password')}`" name="password" :rules="formRules.passwordRepeat"> |
|
|
|
class="bg-white dark:!bg-gray-900" |
|
|
|
<a-input-password |
|
|
|
:rules="formRules.password" |
|
|
|
v-model:value="form.passwordRepeat" |
|
|
|
:label="$t('labels.password')" |
|
|
|
size="large" |
|
|
|
:placeholder="$t('labels.password')" |
|
|
|
class="password" |
|
|
|
:persistent-placeholder="true" |
|
|
|
:placeholder="`Repeat ${$t('labels.password')}`" |
|
|
|
type="password" |
|
|
|
@focus="resetError" |
|
|
|
@focus="resetError" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<v-text-field |
|
|
|
|
|
|
|
id="password_repeat" |
|
|
|
|
|
|
|
v-model="form.passwordRepeat" |
|
|
|
|
|
|
|
class="bg-white dark:!bg-gray-900" |
|
|
|
|
|
|
|
:rules="formRules.passwordRepeat" |
|
|
|
|
|
|
|
:label="`Repeat ${$t('labels.password')}`" |
|
|
|
|
|
|
|
:placeholder="`Repeat ${$t('labels.password')}`" |
|
|
|
|
|
|
|
:persistent-placeholder="true" |
|
|
|
|
|
|
|
type="password" |
|
|
|
|
|
|
|
@focus="resetError" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="self-center flex flex-wrap gap-4 items-center mt-4 md:mx-8 md:justify-between justify-center w-full"> |
|
|
|
<div class="self-center flex flex-wrap gap-4 items-center mt-4 md:mx-8 md:justify-between justify-center w-full"> |
|
|
|
<button |
|
|
|
<button class="submit" type="submit"> |
|
|
|
:disabled="!valid" |
|
|
|
|
|
|
|
:class="[ |
|
|
|
|
|
|
|
!valid |
|
|
|
|
|
|
|
? '!opacity-50 !cursor-default' |
|
|
|
|
|
|
|
: 'text-white bg-primary hover:(text-primary !bg-primary/75) dark:(!bg-secondary/75 hover:!bg-secondary/50)', |
|
|
|
|
|
|
|
]" |
|
|
|
|
|
|
|
class="ml-1 border-1 border-solid border-gray-300 rounded-lg p-4 bg-gray-100/50" |
|
|
|
|
|
|
|
type="submit" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<span class="flex items-center gap-2"><MaterialSymbolsRocketLaunchOutline /> {{ $t('general.signUp') }}</span> |
|
|
|
<span class="flex items-center gap-2"><MaterialSymbolsRocketLaunchOutline /> {{ $t('general.signUp') }}</span> |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
<div class="text-end prose-sm"> |
|
|
|
<div class="text-end prose-sm"> |
|
|
@ -137,6 +139,29 @@ const resetError = () => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</v-form> |
|
|
|
</a-form> |
|
|
|
</NuxtLayout> |
|
|
|
</NuxtLayout> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
|
|
|
|
.signup { |
|
|
|
|
|
|
|
.ant-input-affix-wrapper, |
|
|
|
|
|
|
|
.ant-input { |
|
|
|
|
|
|
|
@apply dark:(bg-gray-700 !text-white) !appearance-none my-1 border-1 border-solid border-primary/50 rounded; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.password { |
|
|
|
|
|
|
|
input { |
|
|
|
|
|
|
|
@apply !border-none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.ant-input-password-icon { |
|
|
|
|
|
|
|
@apply dark:!text-white; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.submit { |
|
|
|
|
|
|
|
@apply ml-1 bordered border-gray-300 rounded-lg p-4 bg-gray-100/50 text-white bg-primary hover:bg-primary/75 dark:(!bg-secondary/75 hover:!bg-secondary/50); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</style> |
|
|
|