From 621792ac7ad0ca46b236051d76328833ce616803 Mon Sep 17 00:00:00 2001 From: Craig Kaiser Date: Mon, 30 Sep 2024 17:39:54 -0400 Subject: [PATCH] password reset --- src/routes/auth/recovery/+page.svelte | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/routes/auth/recovery/+page.svelte b/src/routes/auth/recovery/+page.svelte index 59d779c..77cccfd 100644 --- a/src/routes/auth/recovery/+page.svelte +++ b/src/routes/auth/recovery/+page.svelte @@ -10,15 +10,20 @@ let newPassword: string = ''; async function resetPassword() { - await data.supabase.auth - .updateUser({ password: newPassword }) - .then((_) => { - toast.success('Password updated successfully'); - goto('/protected-routes/dashboard'); - }) - .catch((err) => { - toast.error(err.message); + try { + const { data: userData, error } = await data.supabase.auth.updateUser({ + password: newPassword }); + + if (error) { + throw error; + } + + toast.success('Password updated successfully'); + goto('/protected-routes/dashboard'); + } catch (err) { + toast.error(err.message || 'Failed to update password'); + } } const whoAmI = data?.user?.email;