Fixing seeding and migrations. Fixing other login flows and the check for being fully authenticated. Still need to refactor landing page to mitigate bypassing 2FA.

This commit is contained in:
Bradley Shellnut 2024-06-14 19:11:18 -07:00
parent 43877868a4
commit ad20f88b84
27 changed files with 3593 additions and 177 deletions

View file

@ -1,17 +1,18 @@
import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';
import env from './src/env';
export default defineConfig({
dialect: 'postgresql',
schema: './src/db/schema/index.ts',
out: './src/db/migrations',
dbCredentials: {
host: process.env.DATABASE_HOST || 'localhost',
port: Number(process.env.DATABASE_PORT) || 5432,
user: process.env.DATABASE_USER,
password: process.env.DATABASE_PASSWORD,
database: process.env.DATABASE_DB || 'boredgame',
ssl: process.env.DATABASE_HOST !== 'localhost',
host: env.DATABASE_HOST || 'localhost',
port: Number(env.DATABASE_PORT) || 5432,
user: env.DATABASE_USER,
password: env.DATABASE_PASSWORD,
database: env.DATABASE_DB || 'boredgame',
ssl: env.DATABASE_HOST !== 'localhost',
},
// Print all statements
verbose: true,

View file

@ -25,9 +25,9 @@
"@melt-ui/svelte": "^0.81.0",
"@playwright/test": "^1.44.1",
"@resvg/resvg-js": "^2.6.2",
"@sveltejs/adapter-auto": "^3.2.1",
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/enhanced-img": "^0.2.1",
"@sveltejs/kit": "^2.5.10",
"@sveltejs/kit": "^2.5.14",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/cookie": "^0.6.0",
"@types/node": "^20.14.2",
@ -45,9 +45,9 @@
"postcss-import": "^16.1.0",
"postcss-load-config": "^5.1.0",
"postcss-preset-env": "^9.5.14",
"prettier": "^3.3.1",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.4",
"sass": "^1.77.4",
"sass": "^1.77.5",
"satori": "^0.10.13",
"satori-html": "^0.3.2",
"svelte": "^4.2.18",
@ -62,9 +62,9 @@
"tailwindcss": "^3.4.4",
"ts-node": "^10.9.2",
"tslib": "^2.6.3",
"tsx": "^4.15.1",
"tsx": "^4.15.4",
"typescript": "^5.4.5",
"vite": "^5.2.13",
"vite": "^5.3.1",
"vitest": "^1.6.0",
"zod": "^3.23.8"
},
@ -81,7 +81,7 @@
"@lukeed/uuid": "^2.0.1",
"@neondatabase/serverless": "^0.9.3",
"@paralleldrive/cuid2": "^2.2.2",
"@sveltejs/adapter-vercel": "^5.3.1",
"@sveltejs/adapter-vercel": "^5.3.2",
"@types/feather-icons": "^4.29.4",
"@vercel/og": "^0.5.20",
"bits-ui": "^0.21.10",

View file

@ -30,8 +30,8 @@ importers:
specifier: ^2.2.2
version: 2.2.2
'@sveltejs/adapter-vercel':
specifier: ^5.3.1
version: 5.3.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))
specifier: ^5.3.2
version: 5.3.2(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))
'@types/feather-icons':
specifier: ^4.29.4
version: 4.29.4
@ -67,7 +67,7 @@ importers:
version: 4.29.2
formsnap:
specifier: ^1.0.0
version: 1.0.0(svelte@4.2.18)(sveltekit-superforms@2.15.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18))
version: 1.0.0(svelte@4.2.18)(sveltekit-superforms@2.15.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18))
html-entities:
specifier: ^2.5.2
version: 2.5.2
@ -139,17 +139,17 @@ importers:
specifier: ^2.6.2
version: 2.6.2
'@sveltejs/adapter-auto':
specifier: ^3.2.1
version: 3.2.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))
specifier: ^3.2.2
version: 3.2.2(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))
'@sveltejs/enhanced-img':
specifier: ^0.2.1
version: 0.2.1(rollup@4.18.0)(svelte@4.2.18)
'@sveltejs/kit':
specifier: ^2.5.10
version: 2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
specifier: ^2.5.14
version: 2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
'@sveltejs/vite-plugin-svelte':
specifier: ^3.1.1
version: 3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
version: 3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
'@types/cookie':
specifier: ^0.6.0
version: 0.6.0
@ -194,19 +194,19 @@ importers:
version: 16.1.0(postcss@8.4.38)
postcss-load-config:
specifier: ^5.1.0
version: 5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1)
version: 5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4)
postcss-preset-env:
specifier: ^9.5.14
version: 9.5.14(postcss@8.4.38)
prettier:
specifier: ^3.3.1
version: 3.3.1
specifier: ^3.3.2
version: 3.3.2
prettier-plugin-svelte:
specifier: ^3.2.4
version: 3.2.4(prettier@3.3.1)(svelte@4.2.18)
version: 3.2.4(prettier@3.3.2)(svelte@4.2.18)
sass:
specifier: ^1.77.4
version: 1.77.4
specifier: ^1.77.5
version: 1.77.5
satori:
specifier: ^0.10.13
version: 0.10.13
@ -218,7 +218,7 @@ importers:
version: 4.2.18
svelte-check:
specifier: ^3.8.0
version: 3.8.0(postcss-load-config@5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1))(postcss@8.4.38)(sass@1.77.4)(svelte@4.2.18)
version: 3.8.0(postcss-load-config@5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4))(postcss@8.4.38)(sass@1.77.5)(svelte@4.2.18)
svelte-headless-table:
specifier: ^0.18.2
version: 0.18.2(svelte@4.2.18)
@ -227,19 +227,19 @@ importers:
version: 3.1.2(svelte@4.2.18)(typescript@5.4.5)
svelte-preprocess:
specifier: ^5.1.4
version: 5.1.4(postcss-load-config@5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1))(postcss@8.4.38)(sass@1.77.4)(svelte@4.2.18)(typescript@5.4.5)
version: 5.1.4(postcss-load-config@5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4))(postcss@8.4.38)(sass@1.77.5)(svelte@4.2.18)(typescript@5.4.5)
svelte-sequential-preprocessor:
specifier: ^2.0.1
version: 2.0.1
sveltekit-flash-message:
specifier: ^2.4.4
version: 2.4.4(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)
version: 2.4.4(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)
sveltekit-rate-limiter:
specifier: ^0.5.1
version: 0.5.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))
version: 0.5.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))
sveltekit-superforms:
specifier: ^2.15.1
version: 2.15.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)
version: 2.15.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)
tailwindcss:
specifier: ^3.4.4
version: 3.4.4(ts-node@10.9.2(@types/node@20.14.2)(typescript@5.4.5))
@ -250,17 +250,17 @@ importers:
specifier: ^2.6.3
version: 2.6.3
tsx:
specifier: ^4.15.1
version: 4.15.1
specifier: ^4.15.4
version: 4.15.4
typescript:
specifier: ^5.4.5
version: 5.4.5
vite:
specifier: ^5.2.13
version: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
specifier: ^5.3.1
version: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
vitest:
specifier: ^1.6.0
version: 1.6.0(@types/node@20.14.2)(sass@1.77.4)
version: 1.6.0(@types/node@20.14.2)(sass@1.77.5)
zod:
specifier: ^3.23.8
version: 3.23.8
@ -1823,21 +1823,21 @@ packages:
'@sodaru/yup-to-json-schema@2.0.1':
resolution: {integrity: sha512-lWb0Wiz8KZ9ip/dY1eUqt7fhTPmL24p6Hmv5Fd9pzlzAdw/YNcWZr+tiCT4oZ4Zyxzi9+1X4zv82o7jYvcFxYA==}
'@sveltejs/adapter-auto@3.2.1':
resolution: {integrity: sha512-/3xx8ZFCD5UBc/7AbyXkFF3HNCzWAp2xncH8HA4doGjoGQEN7PmwiRx4Y9nOzi4mqDqYYUic0gaIAE2khWWU4Q==}
'@sveltejs/adapter-auto@3.2.2':
resolution: {integrity: sha512-Mso5xPCA8zgcKrv+QioVlqMZkyUQ5MjDJiEPuG/Z7cV/5tmwV7LmcVWk5tZ+H0NCOV1x12AsoSpt/CwFwuVXMA==}
peerDependencies:
'@sveltejs/kit': ^2.0.0
'@sveltejs/adapter-vercel@5.3.1':
resolution: {integrity: sha512-0iz+Y2ZWM1royXNkNS4TGNYFsMazRckYN+GrJsRq1utzss1Xfoax7C5eafzrsQLPitoLeXBgE31K5abrJ7UgxA==}
'@sveltejs/adapter-vercel@5.3.2':
resolution: {integrity: sha512-3nRBF9OHS14kM8yAZgR4Mu5gO5bAs1HXYGZFZwZrOOClo+jWbeHFn86fkj7yP5CSAu9aw2zVFxJbJrh9ZDFLUg==}
peerDependencies:
'@sveltejs/kit': ^2.4.0
'@sveltejs/enhanced-img@0.2.1':
resolution: {integrity: sha512-tEJCtDDSY4Od7YosS2OAHFjGwM09AOHaL97YuqDAnnKLnTpSYJvpLl3r6bLmWDht2ZqoAXfaPsbFJaG9zbQMjw==}
'@sveltejs/kit@2.5.10':
resolution: {integrity: sha512-OqoyTmFG2cYmCFAdBfW+Qxbg8m23H4dv6KqwEt7ofr/ROcfcIl3Z/VT56L22H9f0uNZyr+9Bs1eh2gedOCK9kA==}
'@sveltejs/kit@2.5.14':
resolution: {integrity: sha512-wgn1EbZOmnqbvs1vjWyrQhrdphSqBALGlMa30rbKXYyLLgrUkHzZHxL7MRfQbtmAi1YEbrNBMt9BadfB57w+Qw==}
engines: {node: '>=18.13'}
hasBin: true
peerDependencies:
@ -1963,8 +1963,8 @@ packages:
'@ungap/structured-clone@1.2.0':
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
'@vercel/nft@0.27.1':
resolution: {integrity: sha512-K6upzYHCV1cq2gP83r1o8uNV1vwvAlozvMqp7CEjYWxo0CMI8/4jKcDkVjlypVhrfZ54SXwh9QbH0ZIk/vQCsw==}
'@vercel/nft@0.27.2':
resolution: {integrity: sha512-7LeioS1yE5hwPpQfD3DdH04tuugKjo5KrJk3yK5kAI3Lh76iSsK/ezoFQfzuT08X3ZASQOd1y9ePjLNI9+TxTQ==}
engines: {node: '>=16'}
hasBin: true
@ -2017,6 +2017,11 @@ packages:
engines: {node: '>=0.4.0'}
hasBin: true
acorn@8.12.0:
resolution: {integrity: sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==}
engines: {node: '>=0.4.0'}
hasBin: true
agent-base@6.0.2:
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
engines: {node: '>= 6.0.0'}
@ -2861,6 +2866,10 @@ packages:
resolution: {integrity: sha512-uy2bNX5zQ+tESe+TiC7ilGRz8AtRGmnJH55NC5S0nSUjvvvM2hJHmefHErugGXN4pNv4Qx7vLsnNw9qJ9mtIsw==}
hasBin: true
jiti@1.21.6:
resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==}
hasBin: true
joi@17.13.1:
resolution: {integrity: sha512-vaBlIKCyo4FCUtCm7Eu4QZd/q02bWcxfUO6YSXAZOWF6gzcLBeba8kwotUdYJjDLW8Cz8RywsSOqiNJZW0mNvg==}
@ -3589,8 +3598,8 @@ packages:
prettier: ^3.0.0
svelte: ^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0
prettier@3.3.1:
resolution: {integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==}
prettier@3.3.2:
resolution: {integrity: sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==}
engines: {node: '>=14'}
hasBin: true
@ -3696,8 +3705,8 @@ packages:
sander@0.5.1:
resolution: {integrity: sha512-3lVqBir7WuKDHGrKRDn/1Ye3kwpXaDOMsiRP1wd6wpZW56gJhsbp5RqQpA6JG/P+pkXizygnr1dKR8vzWaVsfA==}
sass@1.77.4:
resolution: {integrity: sha512-vcF3Ckow6g939GMA4PeU7b2K/9FALXk2KF9J87txdHzXbUF9XRQRwSxcAs/fGaTnJeBFd7UoV22j3lzMLdM0Pw==}
sass@1.77.5:
resolution: {integrity: sha512-oDfX1mukIlxacPdQqNb6mV2tVCrnE+P3nVYioy72V5tlk56CPNcO4TCuFcaCRKKfJ1M3lH95CleRS+dVKL2qMg==}
engines: {node: '>=14.0.0'}
hasBin: true
@ -4084,8 +4093,8 @@ packages:
tslib@2.6.3:
resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==}
tsx@4.15.1:
resolution: {integrity: sha512-k/6h17jA1KfUR7SpcteOa880zGmF56s8gMIcSqUR5avyNFi9nlCEKpMiHLrzrqyARGr52A/JablmGey1DEWbCA==}
tsx@4.15.4:
resolution: {integrity: sha512-d++FLCwJLrXaBFtRcqdPBzu6FiVOJ2j+UsvUZPtoTrnYtCGU5CEW7iHXtNZfA2fcRTvJFWPqA6SWBuB0GSva9w==}
engines: {node: '>=18.0.0'}
hasBin: true
@ -4156,8 +4165,8 @@ packages:
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
vite@5.2.13:
resolution: {integrity: sha512-SSq1noJfY9pR3I1TUENL3rQYDQCFqgD+lM6fTRAM8Nv6Lsg5hDLaXkjETVeBt+7vZBCMoibD+6IWnT2mJ+Zb/A==}
vite@5.3.1:
resolution: {integrity: sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
peerDependencies:
@ -5471,15 +5480,15 @@ snapshots:
'@sodaru/yup-to-json-schema@2.0.1':
optional: true
'@sveltejs/adapter-auto@3.2.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))':
'@sveltejs/adapter-auto@3.2.2(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))':
dependencies:
'@sveltejs/kit': 2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/kit': 2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
import-meta-resolve: 4.1.0
'@sveltejs/adapter-vercel@5.3.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))':
'@sveltejs/adapter-vercel@5.3.2(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))':
dependencies:
'@sveltejs/kit': 2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@vercel/nft': 0.27.1
'@sveltejs/kit': 2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
'@vercel/nft': 0.27.2
esbuild: 0.20.2
transitivePeerDependencies:
- encoding
@ -5494,9 +5503,9 @@ snapshots:
- rollup
- svelte
'@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))':
'@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))':
dependencies:
'@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
'@types/cookie': 0.6.0
cookie: 0.6.0
devalue: 5.0.0
@ -5510,28 +5519,28 @@ snapshots:
sirv: 2.0.4
svelte: 4.2.18
tiny-glob: 0.2.9
vite: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
vite: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
'@sveltejs/vite-plugin-svelte-inspector@2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))':
'@sveltejs/vite-plugin-svelte-inspector@2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))':
dependencies:
'@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
debug: 4.3.4
svelte: 4.2.18
vite: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
vite: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
transitivePeerDependencies:
- supports-color
'@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))':
'@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))':
dependencies:
'@sveltejs/vite-plugin-svelte-inspector': 2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/vite-plugin-svelte-inspector': 2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
debug: 4.3.4
deepmerge: 4.3.1
kleur: 4.1.5
magic-string: 0.30.10
svelte: 4.2.18
svelte-hmr: 0.16.0(svelte@4.2.18)
vite: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
vitefu: 0.2.5(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
vite: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
vitefu: 0.2.5(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
transitivePeerDependencies:
- supports-color
@ -5659,12 +5668,12 @@ snapshots:
'@ungap/structured-clone@1.2.0': {}
'@vercel/nft@0.27.1':
'@vercel/nft@0.27.2':
dependencies:
'@mapbox/node-pre-gyp': 1.0.11
'@rollup/pluginutils': 4.2.1
acorn: 8.11.3
acorn-import-attributes: 1.9.5(acorn@8.11.3)
acorn: 8.12.0
acorn-import-attributes: 1.9.5(acorn@8.12.0)
async-sema: 3.1.1
bindings: 1.5.0
estree-walker: 2.0.2
@ -5729,9 +5738,9 @@ snapshots:
abbrev@1.1.1: {}
acorn-import-attributes@1.9.5(acorn@8.11.3):
acorn-import-attributes@1.9.5(acorn@8.12.0):
dependencies:
acorn: 8.11.3
acorn: 8.12.0
acorn-jsx@5.3.2(acorn@8.11.3):
dependencies:
@ -5741,6 +5750,8 @@ snapshots:
acorn@8.11.3: {}
acorn@8.12.0: {}
agent-base@6.0.2:
dependencies:
debug: 4.3.5
@ -6409,11 +6420,11 @@ snapshots:
cross-spawn: 7.0.3
signal-exit: 4.1.0
formsnap@1.0.0(svelte@4.2.18)(sveltekit-superforms@2.15.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)):
formsnap@1.0.0(svelte@4.2.18)(sveltekit-superforms@2.15.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)):
dependencies:
nanoid: 5.0.7
svelte: 4.2.18
sveltekit-superforms: 2.15.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)
sveltekit-superforms: 2.15.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)
fraction.js@4.3.7: {}
@ -6603,6 +6614,9 @@ snapshots:
jiti@1.21.3: {}
jiti@1.21.6:
optional: true
joi@17.13.1:
dependencies:
'@hapi/hoek': 9.3.0
@ -7126,14 +7140,14 @@ snapshots:
postcss: 8.4.38
ts-node: 10.9.2(@types/node@20.14.2)(typescript@5.4.5)
postcss-load-config@5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1):
postcss-load-config@5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4):
dependencies:
lilconfig: 3.1.1
yaml: 2.4.2
optionalDependencies:
jiti: 1.21.3
jiti: 1.21.6
postcss: 8.4.38
tsx: 4.15.1
tsx: 4.15.4
postcss-logical@7.0.1(postcss@8.4.38):
dependencies:
@ -7300,12 +7314,12 @@ snapshots:
prelude-ls@1.2.1: {}
prettier-plugin-svelte@3.2.4(prettier@3.3.1)(svelte@4.2.18):
prettier-plugin-svelte@3.2.4(prettier@3.3.2)(svelte@4.2.18):
dependencies:
prettier: 3.3.1
prettier: 3.3.2
svelte: 4.2.18
prettier@3.3.1: {}
prettier@3.3.2: {}
pretty-format@29.7.0:
dependencies:
@ -7441,7 +7455,7 @@ snapshots:
mkdirp: 0.5.6
rimraf: 2.7.1
sass@1.77.4:
sass@1.77.5:
dependencies:
chokidar: 3.6.0
immutable: 4.3.5
@ -7622,7 +7636,7 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {}
svelte-check@3.8.0(postcss-load-config@5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1))(postcss@8.4.38)(sass@1.77.4)(svelte@4.2.18):
svelte-check@3.8.0(postcss-load-config@5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4))(postcss@8.4.38)(sass@1.77.5)(svelte@4.2.18):
dependencies:
'@jridgewell/trace-mapping': 0.3.25
chokidar: 3.6.0
@ -7631,7 +7645,7 @@ snapshots:
picocolors: 1.0.0
sade: 1.8.1
svelte: 4.2.18
svelte-preprocess: 5.1.4(postcss-load-config@5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1))(postcss@8.4.38)(sass@1.77.4)(svelte@4.2.18)(typescript@5.4.5)
svelte-preprocess: 5.1.4(postcss-load-config@5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4))(postcss@8.4.38)(sass@1.77.5)(svelte@4.2.18)(typescript@5.4.5)
typescript: 5.4.5
transitivePeerDependencies:
- '@babel/core'
@ -7687,7 +7701,7 @@ snapshots:
dependencies:
svelte: 4.2.18
svelte-preprocess@5.1.4(postcss-load-config@5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1))(postcss@8.4.38)(sass@1.77.4)(svelte@4.2.18)(typescript@5.4.5):
svelte-preprocess@5.1.4(postcss-load-config@5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4))(postcss@8.4.38)(sass@1.77.5)(svelte@4.2.18)(typescript@5.4.5):
dependencies:
'@types/pug': 2.0.10
detect-indent: 6.1.0
@ -7697,8 +7711,8 @@ snapshots:
svelte: 4.2.18
optionalDependencies:
postcss: 8.4.38
postcss-load-config: 5.1.0(jiti@1.21.3)(postcss@8.4.38)(tsx@4.15.1)
sass: 1.77.4
postcss-load-config: 5.1.0(jiti@1.21.6)(postcss@8.4.38)(tsx@4.15.4)
sass: 1.77.5
typescript: 5.4.5
svelte-render@2.0.1(svelte@4.2.18):
@ -7736,19 +7750,19 @@ snapshots:
magic-string: 0.30.10
periscopic: 3.1.0
sveltekit-flash-message@2.4.4(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18):
sveltekit-flash-message@2.4.4(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18):
dependencies:
'@sveltejs/kit': 2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/kit': 2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
svelte: 4.2.18
sveltekit-rate-limiter@0.5.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))):
sveltekit-rate-limiter@0.5.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))):
dependencies:
'@isaacs/ttlcache': 1.4.1
'@sveltejs/kit': 2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/kit': 2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
sveltekit-superforms@2.15.1(@sveltejs/kit@2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18):
sveltekit-superforms@2.15.1(@sveltejs/kit@2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18):
dependencies:
'@sveltejs/kit': 2.5.10(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)))(svelte@4.2.18)(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4))
'@sveltejs/kit': 2.5.14(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)))(svelte@4.2.18)(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5))
devalue: 5.0.0
just-clone: 6.2.0
memoize-weak: 1.0.2
@ -7891,7 +7905,7 @@ snapshots:
tslib@2.6.3: {}
tsx@4.15.1:
tsx@4.15.4:
dependencies:
esbuild: 0.21.5
get-tsconfig: 4.7.5
@ -7951,13 +7965,13 @@ snapshots:
transitivePeerDependencies:
- rollup
vite-node@1.6.0(@types/node@20.14.2)(sass@1.77.4):
vite-node@1.6.0(@types/node@20.14.2)(sass@1.77.5):
dependencies:
cac: 6.7.14
debug: 4.3.4
pathe: 1.1.2
picocolors: 1.0.0
vite: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
vite: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
transitivePeerDependencies:
- '@types/node'
- less
@ -7968,21 +7982,21 @@ snapshots:
- supports-color
- terser
vite@5.2.13(@types/node@20.14.2)(sass@1.77.4):
vite@5.3.1(@types/node@20.14.2)(sass@1.77.5):
dependencies:
esbuild: 0.20.2
esbuild: 0.21.5
postcss: 8.4.38
rollup: 4.17.2
optionalDependencies:
'@types/node': 20.14.2
fsevents: 2.3.3
sass: 1.77.4
sass: 1.77.5
vitefu@0.2.5(vite@5.2.13(@types/node@20.14.2)(sass@1.77.4)):
vitefu@0.2.5(vite@5.3.1(@types/node@20.14.2)(sass@1.77.5)):
optionalDependencies:
vite: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
vite: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
vitest@1.6.0(@types/node@20.14.2)(sass@1.77.4):
vitest@1.6.0(@types/node@20.14.2)(sass@1.77.5):
dependencies:
'@vitest/expect': 1.6.0
'@vitest/runner': 1.6.0
@ -8001,8 +8015,8 @@ snapshots:
strip-literal: 2.1.0
tinybench: 2.8.0
tinypool: 0.8.4
vite: 5.2.13(@types/node@20.14.2)(sass@1.77.4)
vite-node: 1.6.0(@types/node@20.14.2)(sass@1.77.4)
vite: 5.3.1(@types/node@20.14.2)(sass@1.77.5)
vite-node: 1.6.0(@types/node@20.14.2)(sass@1.77.5)
why-is-node-running: 2.2.2
optionalDependencies:
'@types/node': 20.14.2

View file

@ -41,6 +41,16 @@ CREATE TABLE IF NOT EXISTS "collections" (
CONSTRAINT "collections_cuid_unique" UNIQUE("cuid")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "expansions" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"cuid" text,
"base_game_id" uuid NOT NULL,
"game_id" uuid NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "expansions_cuid_unique" UNIQUE("cuid")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "external_ids" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"cuid" text,
@ -250,6 +260,18 @@ EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "expansions" ADD CONSTRAINT "expansions_base_game_id_games_id_fk" FOREIGN KEY ("base_game_id") REFERENCES "public"."games"("id") ON DELETE restrict ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "expansions" ADD CONSTRAINT "expansions_game_id_games_id_fk" FOREIGN KEY ("game_id") REFERENCES "public"."games"("id") ON DELETE restrict ON UPDATE cascade;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "games_to_external_ids" ADD CONSTRAINT "games_to_external_ids_game_id_games_id_fk" FOREIGN KEY ("game_id") REFERENCES "public"."games"("id") ON DELETE restrict ON UPDATE cascade;
EXCEPTION
@ -359,6 +381,6 @@ EXCEPTION
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "search_index" ON "games" USING gin ((
setweight(to_tsvector('english', "name"), 'A') ||
setweight(to_tsvector('english', "name"), 'A') ||
setweight(to_tsvector('english', "slug"), 'B')
));

View file

@ -0,0 +1 @@
ALTER TABLE "external_ids" ALTER COLUMN "type" DROP NOT NULL;

View file

@ -0,0 +1,5 @@
DO $$ BEGIN
CREATE TYPE "public"."external_id_type" AS ENUM('game', 'category', 'mechanic', 'publisher', 'designer', 'artist');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;

View file

@ -1,5 +1,5 @@
{
"id": "d62b05e0-f6b5-4fad-b160-bb378e0ad3a0",
"id": "7871a9e4-6916-4122-b200-42a9f21d4c8d",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
@ -338,6 +338,90 @@
}
}
},
"public.expansions": {
"name": "expansions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "gen_random_uuid()"
},
"cuid": {
"name": "cuid",
"type": "text",
"primaryKey": false,
"notNull": false
},
"base_game_id": {
"name": "base_game_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"game_id": {
"name": "game_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"expansions_base_game_id_games_id_fk": {
"name": "expansions_base_game_id_games_id_fk",
"tableFrom": "expansions",
"tableTo": "games",
"columnsFrom": [
"base_game_id"
],
"columnsTo": [
"id"
],
"onDelete": "restrict",
"onUpdate": "cascade"
},
"expansions_game_id_games_id_fk": {
"name": "expansions_game_id_games_id_fk",
"tableFrom": "expansions",
"tableTo": "games",
"columnsFrom": [
"game_id"
],
"columnsTo": [
"id"
],
"onDelete": "restrict",
"onUpdate": "cascade"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"expansions_cuid_unique": {
"name": "expansions_cuid_unique",
"nullsNotDistinct": false,
"columns": [
"cuid"
]
}
}
},
"public.external_ids": {
"name": "external_ids",
"schema": "",
@ -503,7 +587,7 @@
"name": "search_index",
"columns": [
{
"expression": "(\n setweight(to_tsvector('english', \"name\"), 'A') ||\n setweight(to_tsvector('english', \"slug\"), 'B')\n )",
"expression": "(\n\t\t\t\tsetweight(to_tsvector('english', \"name\"), 'A') ||\n setweight(to_tsvector('english', \"slug\"), 'B')\n )",
"asc": true,
"isExpression": true,
"nulls": "last"

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,22 @@
{
"idx": 0,
"version": "7",
"when": 1718038929675,
"tag": "0000_flippant_slyde",
"when": 1718402690897,
"tag": "0000_premium_pepper_potts",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1718404319259,
"tag": "0001_spicy_legion",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1718405257084,
"tag": "0002_third_black_tom",
"breakpoints": true
}
]

View file

@ -2,7 +2,7 @@ import { pgEnum, pgTable, text, uuid } from 'drizzle-orm/pg-core';
import { createId as cuid2 } from '@paralleldrive/cuid2';
import type { InferSelectModel } from 'drizzle-orm';
export const ExternalIdType = pgEnum('external_id_type', [
export const externalIdType = pgEnum('external_id_type', [
'game',
'category',
'mechanic',
@ -16,7 +16,7 @@ const externalIds = pgTable('external_ids', {
cuid: text('cuid')
.unique()
.$defaultFn(() => cuid2()),
type: ExternalIdType('type').notNull(),
type: externalIdType('type'),
externalId: text('external_id').notNull(),
});

View file

@ -20,7 +20,7 @@ export {
wishlist_item_relations,
type WishlistItems,
} from './wishlistItems';
export { default as externalIds, type ExternalIds, type ExternalIdType } from './externalIds';
export { default as externalIds, type ExternalIds, externalIdType } from './externalIds';
export { default as games, gameRelations, type Games } from './games';
export { default as gamesToExternalIds } from './gamesToExternalIds';
export { default as expansions, expansion_relations, type Expansions } from './expansions';

View file

@ -17,12 +17,16 @@ export async function createPasswordResetToken(userId: string): Promise<string>
}
/**
* Checks if the user is fully authenticated.
* Checks if the user is not fully authenticated.
*
* @param user - The user object.
* @param session - The session object.
* @returns True if the user is fully authenticated, otherwise false.
* @returns True if the user is not fully authenticated, otherwise false.
*/
export function userFullyAuthenticated(user: User | null, session: Session | null) {
return user && session && (!session.isTwoFactorAuthEnabled || session.isTwoFactorAuthenticated);
export function userNotFullyAuthenticated(user: User | null, session: Session | null) {
console.log(
'userNotFullyAuthenticated?',
user && session && (!session.isTwoFactorAuthEnabled || session.isTwoFactorAuthenticated),
);
return !user || !session || (session.isTwoFactorAuthEnabled && !session.isTwoFactorAuthenticated);
}

View file

@ -3,12 +3,12 @@ import { forbiddenMessage, notSignedInMessage } from '$lib/flashMessages';
import { eq } from 'drizzle-orm';
import db from '../../../../db';
import { user_roles } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export const load = loadFlash(async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}

View file

@ -2,12 +2,12 @@ import { redirect } from 'sveltekit-flash-message/server';
import type { PageServerLoad } from './$types';
import { notSignedInMessage } from '$lib/flashMessages';
import db from '../../../../../db';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export const load: PageServerLoad = async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}

View file

@ -8,11 +8,11 @@ import { search_schema } from '$lib/zodValidation.js';
import db from '../../../../db';
import { collection_items, collections, games } from '$db/schema';
import { notSignedInMessage } from '$lib/flashMessages';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export async function load(event) {
const { user, session } = event.locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}

View file

@ -8,14 +8,14 @@ import db from '../../../../../db';
import { notSignedInMessage } from '$lib/flashMessages.js';
import { collections, games, collection_items } from '$db/schema';
import { search_schema } from '$lib/zodValidation';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export async function load(event) {
const { locals, params, url } = event;
const { user, session } = locals;
const { id } = params;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
const searchParams = Object.fromEntries(url?.searchParams);
@ -104,7 +104,7 @@ export const actions: Actions = {
add: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
@ -153,7 +153,7 @@ export const actions: Actions = {
create: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
return error(405, 'Method not allowed');
@ -162,7 +162,7 @@ export const actions: Actions = {
delete: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
return error(405, 'Method not allowed');
@ -171,7 +171,7 @@ export const actions: Actions = {
remove: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
const form = await superValidate(event, zod(modifyListGameSchema));

View file

@ -1,12 +1,12 @@
import { redirect } from '@sveltejs/kit';
import type { PageServerLoad } from '../$types';
import { notSignedInMessage } from '$lib/flashMessages';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export async function load(event) {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}

View file

@ -3,13 +3,13 @@ import { superValidate } from 'sveltekit-superforms/server';
import { zod } from 'sveltekit-superforms/adapters';
import type { PageServerLoad } from '../$types';
import { BggForm } from '$lib/zodValidation';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
import { notSignedInMessage } from '$lib/flashMessages';
export const load: PageServerLoad = async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}

View file

@ -2,12 +2,12 @@ import { fail } from '@sveltejs/kit';
import { eq } from 'drizzle-orm';
import db from '../../../../db';
import { wishlists } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
import { notSignedInMessage } from '$lib/flashMessages';
export async function load({ locals }) {
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
throw fail(401);
}

View file

@ -5,13 +5,13 @@ import { superValidate } from 'sveltekit-superforms/server';
import db from '../../../../../db';
import { modifyListGameSchema } from '$lib/validations/zod-schemas';
import { games, wishlist_items, wishlists } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
import { notSignedInMessage } from '$lib/flashMessages';
export async function load(event) {
const { params, locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
@ -44,7 +44,7 @@ export const actions: Actions = {
add: async (event) => {
const { params, locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
const form = await superValidate(event, zod(modifyListGameSchema));
@ -102,7 +102,7 @@ export const actions: Actions = {
create: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
},
@ -110,7 +110,7 @@ export const actions: Actions = {
delete: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
},
@ -118,7 +118,7 @@ export const actions: Actions = {
remove: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
},

View file

@ -9,17 +9,15 @@ import { notSignedInMessage } from '$lib/flashMessages';
import db from '../../../../db';
import type { PageServerLoad } from './$types';
import { users } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export const load: PageServerLoad = async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
const { user } = event.locals;
const dbUser = await db.query.users.findFirst({
where: eq(users.id, user.id),
});

View file

@ -11,13 +11,13 @@ import { lucia } from '$lib/server/auth.js';
import { users } from '$db/schema';
import { notSignedInMessage } from '$lib/flashMessages';
import type { Cookie } from 'lucia';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export const load: PageServerLoad = async (event) => {
const form = await superValidate(event, zod(changeUserPasswordSchema));
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
@ -35,7 +35,7 @@ export const actions: Actions = {
default: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}

View file

@ -12,8 +12,8 @@ import type { PageServerLoad } from '../../$types';
import { addTwoFactorSchema, removeTwoFactorSchema } from '$lib/validations/account';
import { notSignedInMessage } from '$lib/flashMessages';
import db from '../../../../../../db';
import { recovery_codes, users } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { recoveryCodes, users } from '$db/schema';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export const load: PageServerLoad = async (event) => {
const addTwoFactorForm = await superValidate(event, zod(addTwoFactorSchema));
@ -21,7 +21,7 @@ export const load: PageServerLoad = async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
@ -69,9 +69,9 @@ export const load: PageServerLoad = async (event) => {
export const actions: Actions = {
enableTwoFactor: async (event) => {
const { params, locals } = event;
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
@ -91,8 +91,6 @@ export const actions: Actions = {
return fail(401);
}
const user = event.locals.user;
const dbUser = await db.query.users.findFirst({
where: eq(users.id, user.id),
});
@ -187,7 +185,7 @@ export const actions: Actions = {
.update(users)
.set({ two_factor_enabled: false, two_factor_secret: null })
.where(eq(users.id, user.id));
await db.delete(recovery_codes).where(eq(recovery_codes.userId, user.id));
await db.delete(recoveryCodes).where(eq(recoveryCodes.userId, user.id));
setFlash({ type: 'success', message: 'Two-Factor Authentication has been disabled.' }, cookies);
return {

View file

@ -5,13 +5,13 @@ import { alphabet, generateRandomString } from 'oslo/crypto';
import { redirect } from 'sveltekit-flash-message/server';
import { notSignedInMessage } from '$lib/flashMessages';
import type { PageServerLoad } from '../../../$types';
import { recovery_codes, users } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { recoveryCodes, users } from '$db/schema';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export const load: PageServerLoad = async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
@ -20,19 +20,19 @@ export const load: PageServerLoad = async (event) => {
});
if (dbUser?.two_factor_enabled) {
const recoveryCodes = await db.query.recovery_codes.findMany({
where: eq(recovery_codes.userId, user.id),
const dbRecoveryCodes = await db.query.recoveryCodes.findMany({
where: eq(recoveryCodes.userId, user.id),
});
if (recoveryCodes.length === 0) {
const recoveryCodes = Array.from({ length: 5 }, () =>
if (dbRecoveryCodes.length === 0) {
const createdRecoveryCodes = Array.from({ length: 5 }, () =>
generateRandomString(10, alphabet('A-Z', '0-9')),
);
if (recoveryCodes) {
for (const code of recoveryCodes) {
if (createdRecoveryCodes) {
for (const code of createdRecoveryCodes) {
const hashedCode = await new Argon2id().hash(code);
console.log('Inserting recovery code', code, hashedCode);
await db.insert(recovery_codes).values({
await db.insert(recoveryCodes).values({
userId: user.id,
code: hashedCode,
});

View file

@ -7,12 +7,12 @@ import { modifyListGameSchema } from '$lib/validations/zod-schemas';
import db from '../../../../db';
import { notSignedInMessage } from '$lib/flashMessages.js';
import { games, wishlist_items, wishlists } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export async function load(event) {
const { params, locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
@ -41,7 +41,7 @@ export const actions: Actions = {
add: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
const form = await superValidate(event, zod(modifyListGameSchema));
@ -89,7 +89,7 @@ export const actions: Actions = {
create: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
return error(405, 'Method not allowed');
@ -98,7 +98,7 @@ export const actions: Actions = {
delete: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
return error(405, 'Method not allowed');
@ -107,7 +107,7 @@ export const actions: Actions = {
remove: async (event) => {
const { params, locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
const form = await superValidate(event, zod(modifyListGameSchema));

View file

@ -7,13 +7,13 @@ import { modifyListGameSchema } from '$lib/validations/zod-schemas';
import db from '../../../../../db';
import { notSignedInMessage } from '$lib/flashMessages.js';
import { games, wishlist_items, wishlists } from '$db/schema';
import { userFullyAuthenticated } from '$lib/server/auth-utils';
import { userNotFullyAuthenticated } from '$lib/server/auth-utils';
export async function load(event) {
const { params, locals } = event;
const { user, session } = locals;
const { id } = params;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
redirect(302, '/login', notSignedInMessage, event);
}
@ -44,7 +44,7 @@ export const actions: Actions = {
add: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
const form = await superValidate(event, zod(modifyListGameSchema));
@ -92,7 +92,7 @@ export const actions: Actions = {
create: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
return error(405, 'Method not allowed');
@ -101,7 +101,7 @@ export const actions: Actions = {
delete: async ({ locals }) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
return error(405, 'Method not allowed');
@ -110,7 +110,7 @@ export const actions: Actions = {
remove: async (event) => {
const { locals } = event;
const { user, session } = locals;
if (userFullyAuthenticated(user, session)) {
if (userNotFullyAuthenticated(user, session)) {
return fail(401);
}
const form = await superValidate(event, zod(modifyListGameSchema));