3 Commits

Author SHA1 Message Date
Roman Krček
e616165a77 Fix service worker mess 2025-09-03 10:38:30 +02:00
Roman Krček
238d2eebc5 Fix worker reloads 2025-09-03 10:22:59 +02:00
Roman Krček
aedf260551 Fixed problem where auth is bypassed 2025-09-03 10:17:20 +02:00
6 changed files with 22 additions and 20 deletions

View File

@@ -25,9 +25,6 @@
onMount(async () => {
await authManager.checkConnection();
if (authState.isConnected && authState.token) {
onSuccess?.(authState.token);
}
});
async function handleConnect() {

View File

@@ -1,6 +1,6 @@
import { google } from 'googleapis';
import { getAuthenticatedClient } from '../auth/server.js';
import { GoogleSheet } from './types';
import { GoogleSheet } from './types.ts';
// Type for sheet data
export interface SheetData {

View File

@@ -5,7 +5,7 @@
<h1 class="text-3xl font-bold text-center mb-2">ScanWave</h1>
<h2 class="text-lg text-gray-600 text-center mb-8">Make entrance to your events a breeze.</h2>
<div class="flex space-x-4 w-full justify-center">
<a href="/private/home" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300 w-64 text-center transition" data-sveltekit-reload>
<a href="/private/home" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300 w-64 text-center transition">
Get started
</a>
</div>

View File

@@ -17,7 +17,7 @@
</script>
<nav class="border-b border-gray-300 bg-gray-50 p-2 text-gray-900">
<div class="container mx-auto max-w-4xl p-2">
<div class="container mx-auto max-w-2xl p-2">
<div class="flex items-center justify-between">
<a href="/private/home" class="text-lg font-bold" aria-label="ScanWave Home">ScanWave</a>
@@ -32,7 +32,7 @@
</nav>
<div class="container mx-auto max-w-4xl bg-white p-2">
<div class="container mx-auto max-w-2xl bg-white p-2">
<QueryClientProvider client={queryClient}>
{@render children()}
</QueryClientProvider>

View File

@@ -57,7 +57,7 @@
{$debouncedSearch ? `Search Results: "${$debouncedSearch}"` : 'All Events'}
</h1>
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 mx-auto mb-10">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 max-w-2xl mx-auto mb-10">
{#if isLoading}
<!-- Loading placeholders -->
{#each Array(4) as _}

View File

@@ -16,7 +16,7 @@ self.addEventListener('install', (event: ExtendableEvent) => {
await cache.addAll(ASSETS);
};
console.log(`[SW] Installing new service worker, cache name: ${CACHE}`);
console.log("[SW] Installing new service worker");
event.waitUntil(addFilesToCache());
self.skipWaiting();
@@ -37,29 +37,34 @@ self.addEventListener('activate', (event: ExtendableEvent) => {
self.addEventListener('fetch', (event: FetchEvent) => {
if (event.request.method !== 'GET') return;
// For navigation requests, always fetch from the network to ensure
// server-side authentication checks are performed.
if (event.request.mode === 'navigate') {
const url = new URL(event.request.url);
// Never cache private routes
if (url.pathname.startsWith('/private')) {
event.respondWith(fetch(event.request));
return;
}
// For other requests (e.g., static assets), use a cache-first strategy.
const respond = async () => {
const cache = await caches.open(CACHE);
const cachedResponse = await cache.match(event.request);
if (cachedResponse) {
return cachedResponse;
if (ASSETS.includes(url.pathname)) {
const cached = await cache.match(url.pathname);
if (cached) return cached;
}
try {
return await fetch(event.request);
} catch {
// If the network fails, and it's not in the cache, it will fail,
// which is the expected behavior for non-navigation requests.
return new Response('Not found', { status: 404 });
const response = await fetch(event.request);
if (response.status === 200 && build.length > 0 && url.pathname.startsWith(`/${build[0]}/`)) {
cache.put(event.request, response.clone());
}
return response;
} catch {
const cached = await cache.match(event.request);
if (cached) return cached;
}
return new Response('Not found', { status: 404 });
};
event.respondWith(respond());