mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-21 14:03:32 -07:00
fix user registration form validation
This commit is contained in:
parent
410dbb4fea
commit
eab4387251
1 changed files with 13 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { useAsyncValidator } from "~/composables/use-validators";
|
import { useAsyncValidator } from "~/composables/use-validators";
|
||||||
import type { VForm } from "~/types/vuetify";
|
import type { VForm } from "~/types/auto-forms";
|
||||||
import { usePublicApi } from "~/composables/api/api-client";
|
import { usePublicApi } from "~/composables/api/api-client";
|
||||||
|
|
||||||
const domAccountForm = ref<VForm | null>(null);
|
const domAccountForm = ref<VForm | null>(null);
|
||||||
|
@ -13,11 +13,13 @@ const advancedOptions = ref(false);
|
||||||
export const useUserRegistrationForm = () => {
|
export const useUserRegistrationForm = () => {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
|
|
||||||
function safeValidate(form: Ref<VForm | null>) {
|
async function safeValidate(form: Ref<VForm | null>) {
|
||||||
if (form.value && form.value.validate) {
|
if (!form.value) {
|
||||||
return form.value.validate();
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
const result = await form.value.validate();
|
||||||
|
return result.valid;
|
||||||
}
|
}
|
||||||
// ================================================================
|
// ================================================================
|
||||||
// Provide Group Details
|
// Provide Group Details
|
||||||
|
@ -45,11 +47,15 @@ export const useUserRegistrationForm = () => {
|
||||||
email,
|
email,
|
||||||
advancedOptions,
|
advancedOptions,
|
||||||
validate: async () => {
|
validate: async () => {
|
||||||
if (!(validUsername.value && validEmail.value)) {
|
if (!validUsername.value || !validEmail.value) {
|
||||||
await Promise.all([validateUsername(), validateEmail()]);
|
await Promise.all([validateUsername(), validateEmail()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (safeValidate(domAccountForm as Ref<VForm>) && validUsername.value && validEmail.value);
|
if (!validUsername.value || !validEmail.value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await safeValidate(domAccountForm as Ref<VForm>);
|
||||||
},
|
},
|
||||||
reset: () => {
|
reset: () => {
|
||||||
accountDetails.username.value = "";
|
accountDetails.username.value = "";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue