diff --git a/src/lib/config/zod-schemas.ts b/src/lib/config/zod-schemas.ts index 1013c6d..637a781 100644 --- a/src/lib/config/zod-schemas.ts +++ b/src/lib/config/zod-schemas.ts @@ -44,6 +44,31 @@ export const userSchema = z.object({ updatedAt: z.date().optional() }); +export const signUpSchema = userSchema + .pick({ + firstName: true, + lastName: true, + email: true, + username: true, + password: true, + confirm_password: true, + terms: true + }) + .superRefine(({ confirm_password, password }, ctx) => { + if (confirm_password !== password) { + // ctx.addIssue({ + // code: 'custom', + // message: 'Password and Confirm Password must match', + // path: ['password'] + // }); + ctx.addIssue({ + code: 'custom', + message: ' Password and Confirm Password must match', + path: ['confirm_password'] + }); + } + }); + export const updateUserPasswordSchema = userSchema .pick({ password: true, confirm_password: true }) .superRefine(({ confirm_password, password }, ctx) => { diff --git a/src/routes/auth/signin/+page.svelte b/src/routes/auth/signin/+page.svelte index 3ec0324..e7053fc 100644 --- a/src/routes/auth/signin/+page.svelte +++ b/src/routes/auth/signin/+page.svelte @@ -1,6 +1,8 @@ -
+
+
+
+

+ Sign into your account +

+ + + + + +
+
{#if $errors._errors} @@ -38,18 +63,11 @@ {/if} -
-
-

- Sign into your account -

- - - - - -
-
-
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/src/routes/auth/signup/+page.server.ts b/src/routes/auth/signup/+page.server.ts index f391f18..2fc0ae7 100644 --- a/src/routes/auth/signup/+page.server.ts +++ b/src/routes/auth/signup/+page.server.ts @@ -51,6 +51,8 @@ export const actions = { const form = await superValidate(event, signUpSchema); if (!form.valid) { + form.data.password = ''; + form.data.confirm_password = ''; return fail(400, { form }); diff --git a/src/routes/auth/signup/+page.svelte b/src/routes/auth/signup/+page.svelte index 4216360..a5c176b 100644 --- a/src/routes/auth/signup/+page.svelte +++ b/src/routes/auth/signup/+page.svelte @@ -2,30 +2,24 @@ import { page } from '$app/stores'; import { superForm } from 'sveltekit-superforms/client'; import * as flashModule from 'sveltekit-flash-message/client'; + import toast from 'svelte-french-toast'; import { ChevronsUpDown } from "lucide-svelte"; import Button from '$components/ui/button/Button.svelte'; import Input from '$components/ui/input/Input.svelte'; import Label from '$components/ui/label/Label.svelte'; - import { userSchema } from '$lib/config/zod-schemas.js'; - import toast from 'svelte-french-toast'; + import { signUpSchema } from '$lib/config/zod-schemas.js'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "$components/ui/collapsible"; + import Alert from '$components/ui/alert/Alert.svelte'; + import AlertTitle from '$components/ui/alert/AlertTitle.svelte'; + import AlertDescription from '$components/ui/alert/AlertDescription.svelte'; export let data; let isOpen = false; - const signUpSchema = userSchema.pick({ - firstName: true, - lastName: true, - username: true, - email: true, - password: true, - confirm_password: true - }); - const { form, errors, constraints, enhance, delayed } = superForm(data.form, { flashMessage: { module: flashModule, @@ -109,6 +103,14 @@ + {#if !$form.email} + + Heads up! + + Without an email address, you won't be able to reset your password. Submit only if you are sure. You can always add this later. + + + {/if}