diff --git a/src/lib/auth/index.server.ts b/src/lib/auth/index.server.ts index fc2fcf8..f7a7c50 100644 --- a/src/lib/auth/index.server.ts +++ b/src/lib/auth/index.server.ts @@ -3,6 +3,7 @@ import bcrypt from 'bcrypt'; import sql from '$lib/db/db.server'; import { type Cookies, error } from '@sveltejs/kit'; import jwt from 'jsonwebtoken'; +import type { inquiryTokenPayload } from '$lib/types/inquiries.server'; export function setJWTCookie(cookies: Cookies, user: User) { const payload = { @@ -25,6 +26,17 @@ export function setJWTCookie(cookies: Cookies, user: User) { cookies.set('jwt', JWT, { maxAge, path: '/', httpOnly: false, secure }); } +export function createInquiryToken(payload: inquiryTokenPayload) { + if (process.env.JWT_SECRET === undefined) { + throw Error('JWT_SECRET not defined'); + } + if (process.env.BASE_URL === undefined) { + throw Error('BASE_URL not defined'); + } + + return jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: '30d' }); +} + export function verifyJWT(cookies: Cookies): UserPayload { const JWT = cookies.get('jwt'); if (!JWT) throw error(403, 'Unauthorized'); diff --git a/src/lib/components/custom/claim-item-dialog.svelte b/src/lib/components/custom/claim-item-dialog.svelte new file mode 100644 index 0000000..a255926 --- /dev/null +++ b/src/lib/components/custom/claim-item-dialog.svelte @@ -0,0 +1,82 @@ + + + + + + Claim Item + + Only submit this if you are sure the item is yours.
Claiming the item will remove it from public display. +
+
+ +
+ +
+ + {#if item?.image} + Lost item + {:else} +
+ +
+ + +
+

No image available

+
+ {/if} +
+
{item?.description}
+ {#if item?.foundLocation} +
+ +
{item?.foundLocation}
+
+ {/if} +
+
+ + + + Your Email * + + + +
+ + + + Cancel + + + +
+
+
+ + diff --git a/src/lib/components/custom/edit-item-dialog.svelte b/src/lib/components/custom/edit-item-dialog.svelte new file mode 100644 index 0000000..f4d9d87 --- /dev/null +++ b/src/lib/components/custom/edit-item-dialog.svelte @@ -0,0 +1,147 @@ + + + + + + Manage Item + + It will be updated immediately. + + + +
+
+ + + + + + + Description * + +