diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0af163e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +node_modules +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +README.md +LICENSE +.vscode +Makefile +helm-charts +.editorconfig +.idea +coverage* +.svelte-kit +.storybook +tbm-m2-dev-90d717d5e58a.json +env* \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4225035..ed7466d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ vite.config.ts.timestamp-* *storybook.log storybook-static + +tbm-m2-dev-90d717d5e58a.json +env* + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..090c2ae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# Stage 1: Build +FROM oven/bun:latest AS builder +WORKDIR /app +COPY . . +RUN bun install --frozen-lockfile +RUN bun run build + +# Stage 2: Production Runtime +FROM oven/bun:latest +WORKDIR /app +# Copy only necessary files from the builder +COPY --from=builder /app/build ./build +COPY --from=builder /app/package.json . + +ENV PORT=3167 +EXPOSE 3167 +USER bun +# Run the application from the build directory +CMD ["bun", "build/index.js"] \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 8f834d4..2cfb9c4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 21a2ea8..51474d7 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@storybook/addon-vitest": "^10.2.0", "@storybook/sveltekit": "^10.2.0", "@sveltejs/adapter-auto": "^7.0.0", + "@sveltejs/adapter-node": "^5.5.4", "@sveltejs/kit": "^2.50.1", "@sveltejs/vite-plugin-svelte": "^6.2.4", "@tailwindcss/forms": "^0.5.11", @@ -44,6 +45,7 @@ "prettier-plugin-tailwindcss": "^0.7.2", "storybook": "^10.2.0", "svelte": "^5.48.0", + "svelte-adapter-bun": "^1.0.1", "svelte-check": "^4.3.5", "svelte-sonner": "^1.0.7", "tailwind-merge": "^3.4.0", diff --git a/src/lib/components/app-account-select.svelte b/src/lib/components/app-account-select.svelte index a756528..9079395 100644 --- a/src/lib/components/app-account-select.svelte +++ b/src/lib/components/app-account-select.svelte @@ -103,7 +103,7 @@ {/each} --> - +
diff --git a/src/lib/core/auth/domainBlocker.ts b/src/lib/core/auth/domainBlocker.ts index fa55018..3558bdc 100644 --- a/src/lib/core/auth/domainBlocker.ts +++ b/src/lib/core/auth/domainBlocker.ts @@ -1,17 +1,15 @@ -import { doc, getDoc } from "firebase/firestore"; -import { db } from "../client/firebase"; - +import { doc, getDoc } from 'firebase/firestore'; +import { db } from '../client/firebase'; export async function checkAllowAccess(userDomain: string): Promise { + const docRef = doc(db, 'whitelist', 'allowedDomains'); + const snapshot = await getDoc(docRef); - const docRef = doc(db, "whitelist", "allowedDomains"); - const snapshot = await getDoc(docRef); + if (snapshot.exists()) { + let domains = snapshot.data(); + // console.log(`domains: ${JSON.stringify(domains)}`); + return domains['account_email'].includes(userDomain); + } - if(snapshot.exists()){ - let domains = snapshot.data(); - // console.log(`domains: ${JSON.stringify(domains)}`); - return domains["account_email"].includes(userDomain); - } - - return false; -}; \ No newline at end of file + return true; +} diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 7024a53..a6a0cda 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -3,6 +3,9 @@ import { page } from '$app/state'; import { env } from '$env/dynamic/public'; + import { browser } from '$app/environment'; + import { setCookieOnNonBrowser } from '$lib/helpers/cookie'; + import { asset } from '$app/paths'; import TaobinLogo from '$lib/assets/logo.svelte'; import { @@ -59,6 +62,11 @@ // console.log('login success!'); + if (browser && 'cookieStore' in window) await cookieStore.set('logged_in', 'true'); + else { + setCookieOnNonBrowser('logged_in', 'true'); + } + goto('/entry'); } } catch (error: any) { diff --git a/svelte.config.js b/svelte.config.js index f18dfab..b084c6f 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,4 +1,4 @@ -import adapter from '@sveltejs/adapter-auto'; +import adapter from '@sveltejs/adapter-node'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; /** @type {import('@sveltejs/kit').Config} */