mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 00:04:23 -04:00
fix: User Registration Form Validation and Other Setup Wizard Things (#5920)
This commit is contained in:
@@ -4,7 +4,7 @@ import type { AutoFormItems } from "~/types/auto-forms";
|
||||
export const useCommonSettingsForm = () => {
|
||||
const i18n = useI18n();
|
||||
|
||||
const commonSettingsForm: AutoFormItems = [
|
||||
const commonSettingsForm = computed<AutoFormItems>(() => [
|
||||
{
|
||||
section: i18n.t("profile.group-settings"),
|
||||
label: i18n.t("group.enable-public-access"),
|
||||
@@ -21,7 +21,7 @@ export const useCommonSettingsForm = () => {
|
||||
type: fieldTypes.BOOLEAN,
|
||||
rules: ["required"],
|
||||
},
|
||||
];
|
||||
]);
|
||||
|
||||
return {
|
||||
commonSettingsForm,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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";
|
||||
|
||||
const domAccountForm = ref<VForm | null>(null);
|
||||
@@ -13,11 +13,13 @@ const advancedOptions = ref(false);
|
||||
export const useUserRegistrationForm = () => {
|
||||
const i18n = useI18n();
|
||||
|
||||
function safeValidate(form: Ref<VForm | null>) {
|
||||
if (form.value && form.value.validate) {
|
||||
return form.value.validate();
|
||||
async function safeValidate(form: Ref<VForm | null>) {
|
||||
if (!form.value) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
const result = await form.value.validate();
|
||||
return result.valid;
|
||||
}
|
||||
// ================================================================
|
||||
// Provide Group Details
|
||||
@@ -45,11 +47,15 @@ export const useUserRegistrationForm = () => {
|
||||
email,
|
||||
advancedOptions,
|
||||
validate: async () => {
|
||||
if (!(validUsername.value && validEmail.value)) {
|
||||
if (!validUsername.value || !validEmail.value) {
|
||||
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: () => {
|
||||
accountDetails.username.value = "";
|
||||
|
||||
Reference in New Issue
Block a user