diff --git a/src/db/users.ts b/src/db/users.ts
index de87e15..e493d3b 100644
--- a/src/db/users.ts
+++ b/src/db/users.ts
@@ -1,7 +1,7 @@
import { config } from "$lib/configuration";
import { generateRandomToken } from "$lib/randomToken";
import type { Email, Password, VerificationCode } from "$lib/types";
-import { hash } from "@node-rs/argon2";
+import { hash, verify } from "@node-rs/argon2";
import { db } from ".";
import { usersTable } from "./schema";
import { eq } from "drizzle-orm";
@@ -36,6 +36,22 @@ export async function createNewUser(email: Email, password: Password): Promise<{
}
}
+export async function loadUser(id: number) {
+ const user = await db.select().from(usersTable).where(eq(usersTable.id, id)).limit(1);
+ if (user.length === 0) {
+ return null;
+ }
+ return {
+ id: user[0].id,
+ email: user[0].email as Email,
+ password_hash: user[0].password_hash
+ }
+}
+
+export async function verifyPassword(password: Password, password_hash: string) {
+ return await verify(password_hash, password);
+}
+
export enum VerificationError {
InvalidVerificationCode = 'Invalid verification code',
VerificationCodeExpired = 'Verification code expired'
diff --git a/src/lib/components/PasswordSetterFormPart.svelte b/src/lib/components/PasswordSetterFormPart.svelte
new file mode 100644
index 0000000..e81db3e
--- /dev/null
+++ b/src/lib/components/PasswordSetterFormPart.svelte
@@ -0,0 +1,27 @@
+
+
+
+
+
+
diff --git a/src/lib/components/icons/ProfileIcon.svelte b/src/lib/components/icons/ProfileIcon.svelte
new file mode 100644
index 0000000..5e41cb6
--- /dev/null
+++ b/src/lib/components/icons/ProfileIcon.svelte
@@ -0,0 +1,14 @@
+
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
index 02cf00f..108340e 100644
--- a/src/routes/(app)/+page.svelte
+++ b/src/routes/(app)/+page.svelte
@@ -6,9 +6,30 @@
import Navbar from '$lib/components/Navbar.svelte';
import CheckIcon from '$lib/components/icons/CheckIcon.svelte';
import DuplicateIcon from '$lib/components/icons/DuplicateIcon.svelte';
+ import { page } from '$app/state';
+ import { toast } from '@zerodevx/svelte-toast';
+ import { goto } from '$app/navigation';
+ import ProfileIcon from '$lib/components/icons/ProfileIcon.svelte';
+
+ $effect(() => {
+ if (page.url.searchParams.get('pwd_updated') === 'true') {
+ toast.push('Password update successful', {
+ theme: {
+ '--toastProgressBackground': 'green'
+ },
+ onpop: () => {
+ goto('/');
+ }
+ });
+ }
+ });
-
+ Please provide your old password and the new password twice to update your password. +
+ diff --git a/src/routes/register/+page.svelte b/src/routes/register/+page.svelte index f4a33a1..62bdafa 100644 --- a/src/routes/register/+page.svelte +++ b/src/routes/register/+page.svelte @@ -1,8 +1,9 @@ @@ -19,24 +20,7 @@ {/if} - - - - +