diff --git a/LICENSE b/LICENSE index 7ad0ccb..45b4bfb 100644 --- a/LICENSE +++ b/LICENSE @@ -420,7 +420,7 @@ Section 8 -- Interpretation. Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances -will be considered the “Licensor.” The text of the Creative Commons +will be considered the �Licensor.� The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as diff --git a/README.md b/README.md index bb9436e..7ece81a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ### This is a project to share and record voyage data when sailing. It is my first attempt in svelte. -It uses prisma for Database and lucia for authentication. The project should adhere to EU-GDPR rules. +It uses prisma for Database Management. The project should adhere to EU-GDPR rules. The companion app is written in flutter and is used to inject the data into the database. All API-Endpoints used in the project are also available to the public. Log in via POST to /login and then use the cookie! diff --git a/filePath b/filePath index 4438b9d..f3fe141 100644 Binary files a/filePath and b/filePath differ diff --git a/package.json b/package.json index 3cfaa68..3f0384f 100644 --- a/package.json +++ b/package.json @@ -13,43 +13,39 @@ "format": "prettier --write ." }, "devDependencies": { - "@skeletonlabs/skeleton": "^2.10.3", - "@skeletonlabs/tw-plugin": "^0.4.0", - "@sveltejs/adapter-auto": "^3.3.1", + "@sveltejs/adapter-auto": "^6.0.1", "@sveltejs/adapter-node": "^5.2.9", - "@sveltejs/kit": "^2.7.4", - "@sveltejs/vite-plugin-svelte": "^4.0.0", + "@sveltejs/kit": "^2.21.4", + "@sveltejs/vite-plugin-svelte": "^5.1.0", "@tailwindcss/forms": "^0.5.9", - "@tailwindcss/typography": "0.5.15", + "@tailwindcss/typography": "0.5.16", "@types/leaflet": "^1.9.14", - "@types/node": "22.8.7", - "autoprefixer": "10.4.20", - "postcss": "8.4.47", + "@types/node": "24.0.0", + "autoprefixer": "10.4.21", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", - "prisma": "^6.1.0", + "prisma": "^6.10.1", "svelte": "^5.1.9", "svelte-check": "^4.0.5", - "tailwindcss": "3.4.14", + "tailwindcss": "^4.1.9", "tslib": "^2.8.1", "typescript": "^5.6.3", "utility-types": "^3.11.0", - "vite": "^5.4.10", - "vite-plugin-tailwind-purgecss": "0.3.3" + "vite": "^6.3.5" }, "type": "module", "dependencies": { - "@lucia-auth/adapter-prisma": "^4.0.1", "@node-rs/argon2": "^2.0.0", - "@prisma/client": "^6.1.0", - "@skeletonlabs/skeleton": "^2.10.3", - "@skeletonlabs/tw-plugin": "^0.4.0", - "@sveltejs/adapter-auto": "^3.3.1", + "@prisma/client": "^6.10.1", + "@skeletonlabs/skeleton": "^3.1.3", + "@skeletonlabs/skeleton-svelte": "^1.2.3", + "@sveltejs/adapter-auto": "^6.0.1", "@sveltejs/adapter-node": "^5.2.9", - "@sveltejs/kit": "^2.7.4", - "@sveltejs/vite-plugin-svelte": "^4.0.0", + "@sveltejs/vite-plugin-svelte": "^5.1.0", "@tailwindcss/forms": "^0.5.9", - "@tailwindcss/typography": "0.5.15", + "@tailwindcss/postcss": "^4.1.10", + "@tailwindcss/typography": "0.5.16", + "@tailwindcss/vite": "^4.1.10", "@tiptap/core": "^2.9.1", "@tiptap/extension-blockquote": "^2.9.1", "@tiptap/extension-bullet-list": "^2.9.1", @@ -63,27 +59,21 @@ "@tiptap/extension-text-align": "^2.9.1", "@tiptap/extension-typography": "^2.9.1", "@types/leaflet": "^1.9.14", - "@types/node": "22.8.7", - "autoprefixer": "10.4.20", + "@types/node": "24.0.0", + "autoprefixer": "10.4.21", "compression": "^1.7.5", - "express": "^4.21.1", + "exif-reader": "^2.0.2", + "express": "^5.1.0", "geolib": "^3.3.4", "isomorphic-dompurify": "^2.16.0", "leaflet": "^1.9.4", - "lucia": "^3.2.2", - "pm2": "^5.4.2", - "postcss": "8.4.47", + "pm2": "^6.0.8", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", - "prisma": "^6.1.0", - "sailblog": "file:", - "sharp": "^0.33.5", + "sharp": "^0.34.2", "svelte-check": "^4.0.5", - "tailwindcss": "3.4.14", "tiptap-extension-resize-image": "^1.1.9", "tslib": "^2.8.1", - "utility-types": "^3.11.0", - "vite": "^5.4.10", - "vite-plugin-tailwind-purgecss": "0.3.3" + "utility-types": "^3.11.0" } } diff --git a/postcss.config.cjs b/postcss.config.cjs index 054c147..f646365 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,6 +1,5 @@ module.exports = { plugins: { - tailwindcss: {}, - autoprefixer: {} + "@tailwindcss/postcss": {}, } }; diff --git a/prisma/dev.db b/prisma/dev.db deleted file mode 100644 index 6bea6f6..0000000 Binary files a/prisma/dev.db and /dev/null differ diff --git a/prisma/migrations/20240824180328_changed_visi_for_trip/migration.sql b/prisma/migrations/20240824180328_changed_visi_for_trip/migration.sql deleted file mode 100644 index a6d563c..0000000 --- a/prisma/migrations/20240824180328_changed_visi_for_trip/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE `trip` MODIFY `visibility` INTEGER NOT NULL DEFAULT 1; diff --git a/prisma/migrations/20240824175652_init/migration.sql b/prisma/migrations/20250610191923_/migration.sql similarity index 74% rename from prisma/migrations/20240824175652_init/migration.sql rename to prisma/migrations/20250610191923_/migration.sql index 8443fdb..64cdf66 100644 --- a/prisma/migrations/20240824175652_init/migration.sql +++ b/prisma/migrations/20250610191923_/migration.sql @@ -4,11 +4,16 @@ CREATE TABLE `User` ( `email` VARCHAR(191) NOT NULL, `firstName` VARCHAR(191) NULL, `lastName` VARCHAR(191) NULL, - `description` VARCHAR(191) NULL, + `description` TEXT NULL, `profilePictureId` VARCHAR(191) NULL, `dateOfBirth` DATETIME(3) NULL, `roleId` VARCHAR(191) NOT NULL DEFAULT 'user', - `activeTripId` VARCHAR(191) NOT NULL, + `activeTripId` VARCHAR(191) NULL, + `crewedLengthSail` INTEGER NOT NULL DEFAULT 0, + `crewedLengthMotor` INTEGER NOT NULL DEFAULT 0, + `skipperedLengthSail` INTEGER NOT NULL DEFAULT 0, + `skipperedLengthMotor` INTEGER NOT NULL DEFAULT 0, + `recalculate` BOOLEAN NOT NULL DEFAULT true, `lastPing` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), UNIQUE INDEX `User_username_key`(`username`), @@ -22,6 +27,9 @@ CREATE TABLE `Session` ( `id` VARCHAR(191) NOT NULL, `userId` VARCHAR(191) NOT NULL, `expiresAt` DATETIME(3) NOT NULL, + `ip` VARCHAR(191) NULL, + `session_created` DATETIME(3) NULL, + `last_use` DATETIME(3) NULL, PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -50,15 +58,16 @@ CREATE TABLE `Key` ( CREATE TABLE `Trip` ( `id` VARCHAR(191) NOT NULL, `name` VARCHAR(191) NOT NULL, - `description` VARCHAR(191) NULL, + `description` TEXT NULL, `startPointId` VARCHAR(191) NULL, `endPointId` VARCHAR(191) NULL, - `start` DATETIME(3) NULL, - `end` DATETIME(3) NULL, `last_update` DATETIME(3) NOT NULL, - `length` DECIMAL(65, 30) NULL, + `length_sail` DECIMAL(65, 30) NULL, + `length_motor` DECIMAL(65, 30) NULL, `skipperName` VARCHAR(191) NULL, - `visibility` BOOLEAN NOT NULL DEFAULT false, + `visibility` INTEGER NOT NULL DEFAULT 1, + `recalculate` BOOLEAN NOT NULL DEFAULT true, + `deleted` BOOLEAN NOT NULL DEFAULT false, UNIQUE INDEX `Trip_startPointId_key`(`startPointId`), UNIQUE INDEX `Trip_endPointId_key`(`endPointId`), @@ -83,11 +92,19 @@ CREATE TABLE `Datapoint` ( PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +-- CreateTable +CREATE TABLE `Location` ( + `name` VARCHAR(191) NOT NULL, + + PRIMARY KEY (`name`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + -- CreateTable CREATE TABLE `Media` ( `id` VARCHAR(191) NOT NULL, `visibility` INTEGER NOT NULL DEFAULT 1, `username` VARCHAR(191) NOT NULL, + `alt` VARCHAR(191) NULL, PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -101,6 +118,15 @@ CREATE TABLE `_crew` ( INDEX `_crew_B_index`(`B`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; +-- CreateTable +CREATE TABLE `_LocationToTrip` ( + `A` VARCHAR(191) NOT NULL, + `B` VARCHAR(191) NOT NULL, + + UNIQUE INDEX `_LocationToTrip_AB_unique`(`A`, `B`), + INDEX `_LocationToTrip_B_index`(`B`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + -- AddForeignKey ALTER TABLE `User` ADD CONSTRAINT `User_profilePictureId_fkey` FOREIGN KEY (`profilePictureId`) REFERENCES `Media`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; @@ -108,7 +134,7 @@ ALTER TABLE `User` ADD CONSTRAINT `User_profilePictureId_fkey` FOREIGN KEY (`pro ALTER TABLE `User` ADD CONSTRAINT `User_roleId_fkey` FOREIGN KEY (`roleId`) REFERENCES `Role`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE `User` ADD CONSTRAINT `User_activeTripId_fkey` FOREIGN KEY (`activeTripId`) REFERENCES `Trip`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `User` ADD CONSTRAINT `User_activeTripId_fkey` FOREIGN KEY (`activeTripId`) REFERENCES `Trip`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `Session` ADD CONSTRAINT `Session_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `User`(`username`) ON DELETE CASCADE ON UPDATE CASCADE; @@ -126,7 +152,7 @@ ALTER TABLE `Trip` ADD CONSTRAINT `Trip_endPointId_fkey` FOREIGN KEY (`endPointI ALTER TABLE `Trip` ADD CONSTRAINT `Trip_skipperName_fkey` FOREIGN KEY (`skipperName`) REFERENCES `User`(`username`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE `Datapoint` ADD CONSTRAINT `Datapoint_tripId_fkey` FOREIGN KEY (`tripId`) REFERENCES `Trip`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `Datapoint` ADD CONSTRAINT `Datapoint_tripId_fkey` FOREIGN KEY (`tripId`) REFERENCES `Trip`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `Media` ADD CONSTRAINT `Media_username_fkey` FOREIGN KEY (`username`) REFERENCES `User`(`username`) ON DELETE RESTRICT ON UPDATE CASCADE; @@ -136,3 +162,9 @@ ALTER TABLE `_crew` ADD CONSTRAINT `_crew_A_fkey` FOREIGN KEY (`A`) REFERENCES ` -- AddForeignKey ALTER TABLE `_crew` ADD CONSTRAINT `_crew_B_fkey` FOREIGN KEY (`B`) REFERENCES `User`(`username`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `_LocationToTrip` ADD CONSTRAINT `_LocationToTrip_A_fkey` FOREIGN KEY (`A`) REFERENCES `Location`(`name`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `_LocationToTrip` ADD CONSTRAINT `_LocationToTrip_B_fkey` FOREIGN KEY (`B`) REFERENCES `Trip`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20250610192019_add_secret_to_session/migration.sql b/prisma/migrations/20250610192019_add_secret_to_session/migration.sql new file mode 100644 index 0000000..e8822ef --- /dev/null +++ b/prisma/migrations/20250610192019_add_secret_to_session/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - Added the required column `secret` to the `Session` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE `session` ADD COLUMN `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250611195546_add_default_secret_for_compatibility/migration.sql b/prisma/migrations/20250611195546_add_default_secret_for_compatibility/migration.sql new file mode 100644 index 0000000..54e5d2b --- /dev/null +++ b/prisma/migrations/20250611195546_add_default_secret_for_compatibility/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE `session` MODIFY `session_created` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3), + MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250619192316_add_permissions_to_role/migration.sql b/prisma/migrations/20250619192316_add_permissions_to_role/migration.sql new file mode 100644 index 0000000..ace15bd --- /dev/null +++ b/prisma/migrations/20250619192316_add_permissions_to_role/migration.sql @@ -0,0 +1,16 @@ +-- AlterTable +ALTER TABLE `role` ADD COLUMN `canAddDatapoint` BOOLEAN NOT NULL DEFAULT true, + ADD COLUMN `canAddMedia` BOOLEAN NOT NULL DEFAULT true, + ADD COLUMN `canDeleteAllTrips` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canDeleteCrewedTrips` BOOLEAN NOT NULL DEFAULT true, + ADD COLUMN `canDeleteOwnTrips` BOOLEAN NOT NULL DEFAULT true, + ADD COLUMN `canEditAllTrips` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canEditAllUser` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canEditOwnTrips` BOOLEAN NOT NULL DEFAULT true, + ADD COLUMN `canEditOwnUser` BOOLEAN NOT NULL DEFAULT true, + ADD COLUMN `canSeeAllMedia` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canViewAllTrips` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canViewAllUserdata` BOOLEAN NOT NULL DEFAULT false; + +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250619201422_formatting/migration.sql b/prisma/migrations/20250619201422_formatting/migration.sql new file mode 100644 index 0000000..97545fd --- /dev/null +++ b/prisma/migrations/20250619201422_formatting/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250621103958_add_missing_trip_permissions/migration.sql b/prisma/migrations/20250621103958_add_missing_trip_permissions/migration.sql new file mode 100644 index 0000000..f740f80 --- /dev/null +++ b/prisma/migrations/20250621103958_add_missing_trip_permissions/migration.sql @@ -0,0 +1,6 @@ +-- AlterTable +ALTER TABLE `role` ADD COLUMN `canCreateAllTrips` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canCreateOwnTrips` BOOLEAN NOT NULL DEFAULT true; + +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250621151500_add_create_user_permission/migration.sql b/prisma/migrations/20250621151500_add_create_user_permission/migration.sql new file mode 100644 index 0000000..a4f5d9e --- /dev/null +++ b/prisma/migrations/20250621151500_add_create_user_permission/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE `role` ADD COLUMN `canCreateUser` BOOLEAN NOT NULL DEFAULT false; + +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250622115518_email_optional_in_db/migration.sql b/prisma/migrations/20250622115518_email_optional_in_db/migration.sql new file mode 100644 index 0000000..714570b --- /dev/null +++ b/prisma/migrations/20250622115518_email_optional_in_db/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; + +-- AlterTable +ALTER TABLE `user` MODIFY `email` VARCHAR(191) NULL; diff --git a/prisma/migrations/20250622121740_/migration.sql b/prisma/migrations/20250622121740_/migration.sql new file mode 100644 index 0000000..85850ad --- /dev/null +++ b/prisma/migrations/20250622121740_/migration.sql @@ -0,0 +1,7 @@ +-- AlterTable +ALTER TABLE `role` ADD COLUMN `canUseMagicLink` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `canViewRoles` BOOLEAN NOT NULL DEFAULT false, + ADD COLUMN `needsPassword` BOOLEAN NOT NULL DEFAULT true; + +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250622151401_make_email_optional/migration.sql b/prisma/migrations/20250622151401_make_email_optional/migration.sql new file mode 100644 index 0000000..97545fd --- /dev/null +++ b/prisma/migrations/20250622151401_make_email_optional/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250622152108_test/migration.sql b/prisma/migrations/20250622152108_test/migration.sql new file mode 100644 index 0000000..08514f8 --- /dev/null +++ b/prisma/migrations/20250622152108_test/migration.sql @@ -0,0 +1,5 @@ +-- DropIndex +DROP INDEX `User_email_key` ON `user`; + +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250623162111_/migration.sql b/prisma/migrations/20250623162111_/migration.sql new file mode 100644 index 0000000..97545fd --- /dev/null +++ b/prisma/migrations/20250623162111_/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; diff --git a/prisma/migrations/20250624192638_trip_media_relation_geolocated_photos/migration.sql b/prisma/migrations/20250624192638_trip_media_relation_geolocated_photos/migration.sql new file mode 100644 index 0000000..c2ecd60 --- /dev/null +++ b/prisma/migrations/20250624192638_trip_media_relation_geolocated_photos/migration.sql @@ -0,0 +1,11 @@ +-- AlterTable +ALTER TABLE `media` ADD COLUMN `created` DATETIME(3) NULL, + ADD COLUMN `lat` DECIMAL(65, 30) NULL, + ADD COLUMN `long` DECIMAL(65, 30) NULL, + ADD COLUMN `tripId` VARCHAR(191) NULL; + +-- AlterTable +ALTER TABLE `session` MODIFY `secret` LONGBLOB NOT NULL; + +-- AddForeignKey +ALTER TABLE `Media` ADD CONSTRAINT `Media_tripId_fkey` FOREIGN KEY (`tripId`) REFERENCES `Trip`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index e5a788a..592fc0b 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "mysql" \ No newline at end of file +# It should be added in your version-control system (e.g., Git) +provider = "mysql" diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0377be6..05b26a5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -13,7 +13,7 @@ datasource db { model User { username String @id @unique - email String @unique + email String? firstName String? lastName String? description String? @db.Text @@ -42,14 +42,43 @@ model Session { userId String expiresAt DateTime user User @relation(references: [username], fields: [userId], onDelete: Cascade) + secret Bytes @default("") ip String? - session_created DateTime? + session_created DateTime? @default(now()) last_use DateTime? } model Role { id String @id users User[] + + //DATAPOINT + canAddDatapoint Boolean @default(true) + + //MEDIA + canSeeAllMedia Boolean @default(false) + canAddMedia Boolean @default(true) + + // TRIPS + canViewAllTrips Boolean @default(false) + canCreateOwnTrips Boolean @default(true) + canCreateAllTrips Boolean @default(false) + canEditOwnTrips Boolean @default(true) + canEditAllTrips Boolean @default(false) + canDeleteOwnTrips Boolean @default(true) + canDeleteCrewedTrips Boolean @default(true) + canDeleteAllTrips Boolean @default(false) + + // USER + canCreateUser Boolean @default(false) + canEditOwnUser Boolean @default(true) + canEditAllUser Boolean @default(false) + canViewAllUserdata Boolean @default(false) + needsPassword Boolean @default(true) + canUseMagicLink Boolean @default(false) + + // ROLES + canViewRoles Boolean @default(false) } model Key { @@ -79,6 +108,7 @@ model Trip { skipperName String? crew User[] @relation("crew") location Location[] + media Media[] @relation("gallery") visibility Int @default(1) // 0: private // 1: logged in // 2: public @@ -121,5 +151,10 @@ model Media { user User @relation("uploader", fields: [username], references: [username]) profilePicture User? @relation("profilePicture") username String + trip Trip? @relation("gallery", fields: [tripId], references: [id]) + tripId String? + created DateTime? + lat Decimal? + long Decimal? alt String? } \ No newline at end of file diff --git a/src/app.css b/src/app.css new file mode 100644 index 0000000..f16e7e1 --- /dev/null +++ b/src/app.css @@ -0,0 +1,17 @@ +@import 'tailwindcss'; + +@import '@skeletonlabs/skeleton'; +@import '@skeletonlabs/skeleton/optional/presets'; +@import "./ocean.css"; + +@source '../node_modules/@skeletonlabs/skeleton-svelte/dist'; +@custom-variant dark (&:where(.dark, .dark *)); + +/* Add your theme import for your theme: "ocean" here */ +@tailwind base; +@tailwind components; +@tailwind utilities; +html, +body { + @apply h-full overflow-hidden; +} diff --git a/src/app.d.ts b/src/app.d.ts index 854830b..cf715b1 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -4,8 +4,9 @@ declare global { declare namespace App { interface Locals { - user: import('lucia').User | null; - session: import('lucia').Session | null; + user: User | null; + session: Session | null; + role: Role | null; } // interface PageData {} // interface Error {} diff --git a/src/app.html b/src/app.html index afe83c4..b97c508 100644 --- a/src/app.html +++ b/src/app.html @@ -1,13 +1,13 @@ - + - + sailBlog - - + + %sveltekit.head% - +
%sveltekit.body%
diff --git a/src/app.postcss b/src/app.postcss deleted file mode 100644 index 4594986..0000000 --- a/src/app.postcss +++ /dev/null @@ -1,8 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; -@tailwind variants; -html, -body { - @apply h-full overflow-hidden; -} diff --git a/src/global.css b/src/global.css index 5a4b590..6ea0955 100644 --- a/src/global.css +++ b/src/global.css @@ -1,6 +1,6 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; +@import 'tailwindcss'; + +@reference "tailwindcss"; h1.ce-header { @apply text-3xl font-bold; diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 3952894..8bbddf1 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,31 +1,19 @@ // src/hooks.server.ts -import { lucia } from '$lib/server/auth'; +import { auth } from '$lib/server/auth'; import { prisma } from '$lib/server/prisma'; import { error, type Handle } from '@sveltejs/kit'; export const handle: Handle = async ({ event, resolve }) => { - const sessionId = event.cookies.get(lucia.sessionCookieName); + const sessionId = event.cookies.get("session_token"); if (!sessionId) { event.locals.user = null; event.locals.session = null; return resolve(event); } - const { session, user } = await lucia.validateSession(sessionId); - if (session && session.fresh) { - const sessionCookie = lucia.createSessionCookie(session.id); - event.cookies.set(sessionCookie.name, sessionCookie.value, { - path: '.', - ...sessionCookie.attributes - }); - } - if (!session) { - const sessionCookie = lucia.createBlankSessionCookie(); - event.cookies.set(sessionCookie.name, sessionCookie.value, { - path: '.', - ...sessionCookie.attributes - }); - }else{ + const {session, user, role} = await auth.validateSession(sessionId); + + if(session != null && user != null){ try{ await prisma.session.update({ where:{ @@ -59,7 +47,11 @@ export const handle: Handle = async ({ event, resolve }) => { } } } + + + event.locals.user = user; event.locals.session = session; + event.locals.role = role; return resolve(event); -}; +} diff --git a/src/lib/Leaflet.svelte b/src/lib/Leaflet.svelte index 239f2b7..980365c 100644 --- a/src/lib/Leaflet.svelte +++ b/src/lib/Leaflet.svelte @@ -4,9 +4,12 @@ import L, { LatLngBounds } from 'leaflet'; import 'leaflet/dist/leaflet.css'; import { onDestroy, onMount, setContext } from 'svelte'; - import { modeCurrent } from '@skeletonlabs/skeleton'; import errorStore from './errorStore'; + import {dark} from './darkMode.svelte'; + + let mode = $state(localStorage.getItem('mode') || 'light'); + let map: L.Map | undefined = $state(); let mapElement: HTMLDivElement = $state(); let lines: L.Polyline[][] = $state([]); @@ -46,6 +49,8 @@ let recenterButton = new recenterButtonStructure(); onMount(() => { + const mode = localStorage.getItem('mode') || 'light'; + document.documentElement.setAttribute('class', mode); map = L.map(mapElement); var osmLayer = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { @@ -256,7 +261,7 @@ {/if} -{#if !$modeCurrent} +{#if dark.mode}