diff --git a/src/lib/config/zod-schemas.ts b/src/lib/config/zod-schemas.ts index 301b518..3988d4f 100644 --- a/src/lib/config/zod-schemas.ts +++ b/src/lib/config/zod-schemas.ts @@ -90,3 +90,31 @@ export const updateUserPasswordSchema = userSchema }); } }); + +export const changeUserPasswordSchema = z + .object({ + current_password: z.string({ required_error: 'Current Password is required' }), + password: z + .string({ required_error: 'Password is required' }) + .trim() + .min(8, { message: 'Password must be at least 8 characters' }) + .max(128, { message: 'Password must be less than 128 characters' }), + confirm_password: z + .string({ required_error: 'Confirm Password is required' }) + .trim() + .min(8, { message: 'Confirm Password must be at least 8 characters' }) + }) + .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'] + }); + } + }); diff --git a/src/routes/(app)/(protected)/list/+layout.svelte b/src/routes/(app)/(protected)/list/+layout.svelte index 071ea58..cbd6fc5 100644 --- a/src/routes/(app)/(protected)/list/+layout.svelte +++ b/src/routes/(app)/(protected)/list/+layout.svelte @@ -1,5 +1,5 @@ + +
+ +

Change Password

+
+ {#if $message} + + {/if} +
+ + + {#if $errors.current_password} + {$errors.current_password} + {/if} +
+
+ + + {#if $errors.password} + {$errors.password} + {/if} +
+
+ + + {#if $errors.confirm_password} + {$errors.confirm_password} + {/if} +
+ +
+ +
+
\ No newline at end of file diff --git a/src/routes/(auth)/password/reset/+page.server.ts b/src/routes/(app)/(protected)/password/reset/+page.server.ts similarity index 100% rename from src/routes/(auth)/password/reset/+page.server.ts rename to src/routes/(app)/(protected)/password/reset/+page.server.ts diff --git a/src/routes/(auth)/password/reset/+page.svelte b/src/routes/(app)/(protected)/password/reset/+page.svelte similarity index 100% rename from src/routes/(auth)/password/reset/+page.svelte rename to src/routes/(app)/(protected)/password/reset/+page.svelte diff --git a/src/routes/(app)/(protected)/profile/+page.svelte b/src/routes/(app)/(protected)/profile/+page.svelte index 4696a1e..6db738a 100644 --- a/src/routes/(app)/(protected)/profile/+page.svelte +++ b/src/routes/(app)/(protected)/profile/+page.svelte @@ -2,7 +2,7 @@ import { superForm } from 'sveltekit-superforms/client'; //import SuperDebug from 'sveltekit-superforms/client/SuperDebug.svelte'; import { userSchema } from '$lib/config/zod-schemas'; - import { AlertTriangle } from 'lucide-svelte'; + import { AlertTriangle, KeyRound } from 'lucide-svelte'; import { Label } from '$components/ui/label'; import { Input } from '$components/ui/input'; import { Button } from '$components/ui/button'; @@ -63,8 +63,10 @@ {/if}
- - +
diff --git a/src/routes/(auth)/sign-up/+page.svelte b/src/routes/(auth)/sign-up/+page.svelte index 9f79a1d..52683d6 100644 --- a/src/routes/(auth)/sign-up/+page.svelte +++ b/src/routes/(auth)/sign-up/+page.svelte @@ -1,5 +1,7 @@