1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-14 15:17:26 +00:00

feat: add the ability to make email optional (#994)

This commit is contained in:
Elias Schneider
2025-10-03 11:24:53 +02:00
committed by GitHub
parent 043cce615d
commit 507f9490fa
44 changed files with 175 additions and 69 deletions

View File

@@ -1,11 +1,13 @@
<script lang="ts">
import FormInput from '$lib/components/form/form-input.svelte';
import { m } from '$lib/paraglide/messages';
import appConfigStore from '$lib/stores/application-configuration-store';
import type { UserSignUp } from '$lib/types/user.type';
import { preventDefault } from '$lib/utils/event-util';
import { createForm } from '$lib/utils/form-util';
import { tryCatch } from '$lib/utils/try-catch-util';
import { emptyToUndefined, usernameSchema } from '$lib/utils/zod-util';
import { get } from 'svelte/store';
import { z } from 'zod/v4';
let {
@@ -27,7 +29,7 @@
firstName: z.string().min(1).max(50),
lastName: emptyToUndefined(z.string().max(50).optional()),
username: usernameSchema,
email: z.email()
email: get(appConfigStore).requireUserEmail ? z.email() : emptyToUndefined(z.email().optional())
});
type FormSchema = typeof formSchema;

View File

@@ -10,6 +10,7 @@ export type AppConfig = {
disableAnimations: boolean;
uiConfigDisabled: boolean;
accentColor: string;
requireUserEmail: boolean;
};
export type AllAppConfig = AppConfig & {

View File

@@ -5,7 +5,7 @@ import type { UserGroup } from './user-group.type';
export type User = {
id: string;
username: string;
email: string;
email: string | undefined;
firstName: string;
lastName?: string;
displayName: string;